Connecting to an ODBC Datasource using a DSN String (Set DynamicallY)

Auerelio Vasquez
Auerelio Vasquez used Ask the Experts™
on
I'm trying to connect to a ODBC-DCN through asp, using a aspx.vb page. The page has two text boxes, one for uid and one for pwd; i want to pass these variables in to the dsn string as shown below:
g_userid = txtg_user_id.text and g_password=txt_pwd.text

     'g_Connect_String = "Driver={CA-IDMS};DICT=OCSQLDTN;NODE=SYST01;" & _
        '"UID=" & g_userid & ";PWD=" & g_password & ";CCINAME=156.132.10.55;CCIPORT=1202"

        'Conn.Open(g_Connect_String) on this one i get an error that says we can't use a string in the odbc settings

     on this on we are simply trying to pass in the user id and password again

   g_Connect_String = "DSN=cv1-p1;UID="  & g_userid & ";pwd="  & g_password

and here we are trying to set a datasource connection string dynamically, and we get an error on the page that says not enough odbc information provided, even before we try do to anything. in fact, when the page loades, it loades with that error:

SqlDataSource1.ConnectionString = ("DSN=cv1-p1;UID="  & g_userid & ";pwd="  & g_password)

is it not possible to do this ? this is a CA-IDMS database...... I know it's old, but all we want to do is connect to the databases, and populate a grid.....
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Top Expert 2008
Commented:
You can't use the SqlDataSource with ODBC, and frankly I don't know if the ObjectDataSource supports ODBC either.

Bob
Auerelio VasquezETL Developer

Author

Commented:
if i use the data source within the asp form, and tie it to the DSN, i can get the data returned.
Most Valuable Expert 2012
Top Expert 2008

Commented:
Then, that's a new one on me.

Bob
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Auerelio VasquezETL Developer

Author

Commented:
i just want to assign the dsn connection string dynamically.

therefore sqldatasource1.connectionstring = ("DSN=cv1-p1;UID="  & g_userid & ";pwd="  & g_password)

is this not possible ?
Auerelio VasquezETL Developer

Author

Commented:
the way to connect is to use the following lines:

        g_password = txt_password.Text
        g_userid = txt_userid.Text
        g_select_string = srch_userid.Text
        Dim oODBCConnection As New Odbc.OdbcConnection
        Dim sConnString As String = "DSN=cv1-p1;UID=" & g_userid & ";" & "pwd=" & g_password & ""
        oODBCConnection = New Odbc.OdbcConnection(sConnString)

it connects to the IDMS database with no problem.... Just for an FYI.
Most Valuable Expert 2012
Top Expert 2008

Commented:
>>if i use the data source within the asp form, and tie it to the DSN, i can get the data returned.

Are you saying that you used an OdbcConnection to get to the data or an SqlDataSource?

Bob
Auerelio VasquezETL Developer

Author

Commented:
i used the odbc connection to bind it to the sqldatasource and it returned data from an IDMS database.
Most Valuable Expert 2012
Top Expert 2008

Commented:
I don't quite understand what problem you are having, then.

Bob

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial