We've got an ASP.NET website that uses a database that we want to be able to use a connectionstring to get to. We've successfully set up a DSN for connecting to this DB, but I can't seem to discover the correct magic to go with a connectionstring.
Is there a straightforward way to translate the values from the DSN into a connectionstring? I know that from the UI, there isn't an obvious answer for this...each db vendor provides a different UI for creating a DSN based on what they require. However, I was hoping that underneath the UI it might just be doing something like creating a connection string behind the scenes, and I could look at that to see what I'm doing wrong. Any hope of this? If so, any pointers on how to get the info I need?
(I've gone to connectionstrings.com to try to make sure my connection string is in the right format, but nothing seems to be working...which is why I'm trying this strange translate-from-dsn tact.)
EDIT: Something I must not have been clear on is that we do not want to have a DSN entry. We have created one, and have used it for the time being, but we want to be able to get rid of it and use a connectionstring without a dsn.
Right-click on your connection and select "Properties". You will get the Properties window for your connection. Find the "Connection String" property and select the "connection string". So now your connection string is in your hands; you can use it anywhere you want.
It is the name that applications use to request a connection to an ODBC Data Source. In other words, it is a symbolic name that represents the ODBC connection.
If you have created a DSN, then the DSN is the ConnectionString !
You can simply use DSN=<YourDSNName>
and pass it to an OdbcConnection object.
For instance, using C#:
string dsnName = "DSN=MyDSN";
using (OdbcConnection conn = new OdbcConnection(dsnName))
{
conn.Open();
}
Alternatively, you can use the OdbcConnectionStringBuilder
class and set its DSN
property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With