using odbc in a connection of object

How do I assign a connection object to the odbc driver  I setup in control panel to get to the database.  I know how to assign the server, but in some case I need to use the ip address and in others just the server name, so I just rather setup a odbc driver and have the connection object look at that.

thanks
mgmhicksAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sajuksCommented:
Check http://www.connectionstrings.com/ to setup your odbc connections strings.
Eg:for mysql
SERVER=10.160.0.101 'assumeing thats your ip
DRIVER={MySQL ODBC 3.51 Driver};DESC=;DATABASE=MyDevlpm;SERVER=10.160.0.101;UID=xxx;PASSWORD=abc;PORT=;OPTION=0;STMT=;
0
DabasCommented:
Hi mgmhicks,
Use this as your connection string:

DSN=MyDSN;UID=user;DATABASE=MyDatabase;PWD=MyPassword;

Failing that, drag an ODBC connection from the Data in your toolbox to the form, rightclick on it go to properties, then manually set the connection.
Check the resulting connectionstring

Dabas
0
DabasCommented:
sajuks,
That is a good link you posted there! Thanks!

Dabas
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

mgmhicksAuthor Commented:
Sorry guys that doesnt work.  Need to use a DSN connection in my oleconnection object.  Cant figure out the connection string.
0
mgmhicksAuthor Commented:
It actually took this connection string, but the data adapter configurator doesnt see the connection object on the form.

Provider=sqloledb;Data Source=TandA;Initial Catalog=timemanagment;Integrated Security=SSPI

How do I get a data adapter to use this connection know with the data adapter configurator

0
DabasCommented:
mgmhicks:
Try my connection (without provider = )
DSN=TandA;UID=user;DATABASE=timemanagment;PWD=MyPassword;

Dabas
0
mgmhicksAuthor Commented:
The following took care of the code.  However you must set a reference to odbc.net

        Dim cn As OdbcConnection
        cn = New OdbcConnection("dsn=TandA;uid=shicks;pwd=knicks19;")
        Dim mystring As String = "Select UserName,id from time_employees"
        Dim cmd As OdbcCommand = New OdbcCommand(mystring, cn)
        cn.Open()
0
mgmhicksAuthor Commented:
I ended up putting the correct answer in myself and wasnt sure how to close it after doing that.

0
moduloCommented:
PAQed with no points refunded (of 125)

modulo
Community Support Moderator
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.