Click here to Skip to main content
13,055,490 members (52,572 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I am getting this error while trying to connect Sybase databse from Visual Studio 2010 in C# code.

My App.Config file is like this :
<?xml version="1.0" encoding="utf-8" ?>
    <add key="DSN" value="SYBASE_TEST"></add>
    <add key="Database" value="MYDB"></add>
    <add key="UserId" value="uid"></add>
    <add key="Password" value="pwd"></add>

And my entire C# code is like this :
using System;
using System.Configuration;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Odbc;
namespace SybaseConsoleApp
    class Program
        static string dsn = ConfigurationManager.AppSettings["DSN"];
        static string database = ConfigurationManager.AppSettings["Database"];
        static string userId = ConfigurationManager.AppSettings["UserId"];
        static string password = ConfigurationManager.AppSettings["Password"];        static void Main(string[] args)
            //string connStr = "Driver={Sybase System 11};SRVR=" + dsn + ";DB=" + database + ";UID=" + userId + ";PWD=" + password;
            string connStr = "DSN=" + dsn + ";Uid=" + userId + ";Pwd=" + password + ";Database=" + database;
            OdbcConnection odbcConn = new OdbcConnection();
            odbcConn.ConnectionString = connStr;

And I'm getting the error at line

I'm working in a remote machine and Sybase is in another remote machine.
Please help me as soon as possible.
Thanks in Advance.
Posted 27-Mar-13 9:21am
Updated 27-Mar-13 13:59pm
ryanb31 27-Mar-13 15:36pm
It means there is no odbc connection named SYBASE_TEST on your system.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

There are possible 2 reasons (as good as i know):

It looks like you do not specify a driver for connection string.
//string connStr = "Driver={Sybase System 11};SRVR=" + dsn + ";DB=" + database + ";UID=" + userId + ";PWD=" + password;
            string connStr = "DSN=" + dsn + ";Uid=" + userId + ";Pwd=" + password + ";Database=" + database;

Have a look at commented line and line below this line ;) Do you see the difference?
Tip: I prefer to use String.Format[^] method.
string connStr = Format("DSN={0};Uid={1};Pwd={2};Database={3}",dsn, userId, password, database);

If it not helps, please, see these:[^][^]
How to check if DSN has been properly set up? Using odbcad32.exe application. Read this:[^]

DSN is not availible for some Windows users, because of DSN is User DSN, not system DSN.
Please, read this:[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 27 Mar 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100