Connecting to SQL w/ADO
- From: "G." <noreply@xxxxxxxxxxx>
- Date: Thu, 3 Nov 2005 17:02:06 -0500
Hello all,
I am trying to connect via ADO to our SQL Server backend, but it's not
connecting. I am developing in VB6 SP5.
The code I have is this (relevant to what I am trying to do):
===
in (gen)(dec):
Const PathToSQL = "Initial Catalog=VTIOE;Data Source=SQL"
....
then in the command button that is going to search for the same record I
have this:
cnn.Open "DSN=SQL_VTIOE;User ID=" & gstrUser & ";Password=" & gstrPasswd
& ";" & PathToSQL
rst.Open "SELECT Order_No FROM Shipments WHERE Order_No LIKE '" &
strOrderNo & "'", cnn, adOpenStatic
When I run the code, it flags the cnn.Open line with several different
errors (I tinkered with that line to try and persuade it to work).
Sometimes I get a run-time -214721843 (login failed for user 'username')
others, I get: run-time -2147467259 "Data Source name not found and no
default driver specified."
??
Can anyone help me out and let me know how I should be trying to connect to
the server (SQL Server 2000)? I have connected to Access 2000 databases just
fine in the past, but the SQL connection is new territory for me.
Thanks, in advance, for any and all help!
~Gary
.
- Follow-Ups:
- Re: Connecting to SQL w/ADO
- From: William \(Bill\) Vaughn
- Re: Connecting to SQL w/ADO
- Prev by Date: Re: Access Database Connection Lost Every 30 Seconds
- Next by Date: Re: Connecting to SQL w/ADO
- Previous by thread: Re: Access Database Connection Lost Every 30 Seconds
- Next by thread: Re: Connecting to SQL w/ADO
- Index(es):