ODBC ConnectionString

I wrote a program in C # to pull some data using OdbcConnection:

using System.Data.Odbc; ...... OdbcConnection OdbcConn = new OdbcConnection(Properties.Settings.Default.ConnectionString); OdbcCommand cmd = new OdbcCommand(); //open connection if (OdbcConn.State != ConnectionState.Open) { OdbcConn.Open(); } 

In my settings file, I have a ConnectionString:

Dsn=****;uid=userID;pwd=password

However, I cannot establish a connection. I have an iseries access driver from IBM corp, but if I try MS access, I can connect. Any suggestions?

+6
source share
3 answers

In case of doubt (and it includes connection strings): http://www.connectionstrings.com/

+9
source

On a machine with a 64-bit version of Windows, make sure your C # code is compiled to x86 (32-bit), x64, or Any Processor. Please note that if you compile “Any processor”, x64 bit drivers will be selected by default.

32-bit drivers can be found in C: \ windows \ SysWOW64 \ odbcad32.exe . 32-bit drivers can be found in C: \ windows \ system32 \ odbcad32.exe .

First, make sure that you confirm that your connection is working with the administrator of the ODBC data source using the previously specified paths. That is, make a DSN and test it, as Turbot suggested. After you check this connection, your connection string can only use the created DSN or you can use the free DSN connection string.

For a quick reference, here is an example of a free DSN connection string using the ODBC driver:

Driver = {Progress OpenEdge 11.3 Driver}; HOST = wfdscr11.wf.local; Port = 1234; DB = MyDatabaseName; UID = John; PWD = Doe

In this example, I had to connect to the Progress database from my C # code, and this is the connection string that I used without specifying a DSN. Below you can see that the driver name is "Progress OpenEdge 11.3 Driver".

enter image description here

+3
source

I always like to test the connection using the data source (ODBC) in the control panel (suppose you are in a windows environment). Verify that the drive is available in your ODBC sample and follow the steps to verify connectivity.

as mentioned above, the connection chain website will give you an idea of ​​what properties and format that specific driver support is associated with

0
source

Source: https://habr.com/ru/post/909010/


All Articles