0

I am working on a new asp.net web application which has to connect and use an old legacy database. It is not an RDBMS as SQL Server but instead a C-Treive so I should be using ODBC or in my C#/ASP code. I will be using this namespace:

System.Data.Odbc;

Now, my problem is in Web.Config file. I have not used ODBC for years and every time I run the application it throws an error indicating it is an invalid connection.

` add name="DB_Connection" connectionString="Driver=ODBCDriver;server=172.xxx.xxx.xxx;" providerName="System.Data.Odbc"/>

    internal OdbcConnection OpenConnection()
    {
        OdbcConnection conn = new OdbcConnection(ConnectionString);
        conn.Open();
        return conn;
    } 

`

{"ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"}

This is what I have declared in the Web.Config:

Honestly, I am not sure what would be considered Catalog in this case since it is not SQL Server.

I will appreciate your inputs.

Thanks, Amit

2
  • What is ConnectionString. Need that. Commented Nov 23, 2016 at 20:54
  • This is what I have used and didn't help in web.config file under <connectionStrings> tag: add name="DB_Connection" connectionString="Driver=ODBCDriver;server=172.xxx.xxx.xxx;" providerName="System.Data.Odbc"/> Commented Nov 23, 2016 at 23:47

1 Answer 1

1

You don't have to use a DSN (Data Source Name), it's just that traditionally ODBC used them. A DSN is really just a connection-string that is stored systemwide and referenced by name. Just find the actual, underlying connection-string and then save that in your <connectionStrings> element.

Note that the full ODBC connection string will specify the driver name.

Sign up to request clarification or add additional context in comments.

8 Comments

Dai, thank you for your input but what should I do about the elements that have to be filled in it? e.g. server name, database name? currently, I am using <add name="DB_Connection" connectionString="Driver=ODBCDriver;server=172.xxx.xxx.xxx;" providerName="System.Data.Odbc"/> would it be possible to show me an example? I will appreciate it greatly!
The driver I need to use for the connection is called BBj ODBC Driver so then I changed it to ` <add name="DB_Connection" connectionString="Driver={BBj ODBC Driver};server=172.xxx.xxx.xxx;" providerName="System.Data.Odbc" />` However, when I trace it I can see the database name, driver and DataSource have no value.
@amitkohan I can't really help you with specifics. I believe the product you're using is now called "C-treeRTG" and is maintained by FairCom: faircom.com/products/c-treertg - I suggest you contact them for specific advice with your database system.
sure will do that but by any chance do you know how the format will be? Thank you again!
@amitkohan I don't, sorry.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.