Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to Connect to SQL Server Database Using ADO 1

Status
Not open for further replies.

JohnBates

MIS
Joined
Feb 27, 2000
Messages
1,995
Location
US
hi experts,

The .open stmt below gives error '[DBNETLIB]ConnectionOpen. SQLServer does not exist or access denied'

The SQL server (2000) db is running on this PC.
Is this probably a permissions issue?

Thanks, John

Option Explicit
Public GMcn As ADODB.Connection
Public GMrs As ADODB.Recordset

Public Sub ConnectToSQLServer()

Dim strSQL As String

Set GMcn = New ADODB.Connection
Set GMrs = New ADODB.Recordset

GMcn.ConnectionString = "Provider=sqloledb;Data Source=ELVIS;Initial Catalog=GM;Integrated Security=SSPI;"

strSQL = "Select * From ClmPayments2"
GMcn.Open '<<<-- this is where the error occurs


Call GMrs.Open(strSQL, GMcn, adOpenForwardOnly, adLockReadOnly, adCmdText)
 
Where is the username/password part?

This is usually what i have in my connection string while am using ADO, and when it connects to SQL Server 2000.

Code:
GL_Connectstring = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=MyUserID;pwd=MyPassword;Initial Catalog=myDatabase;Data Source=MyServer"

If you have a problem making this work, you can use ADODC (ADO Datacontrol) to generate the connection string for you. Once you have the connection string and you elect not to use ADODC in your project, you can delete the control from the form and remove its reference from the project via the Components menu.

------------------------------------------
The faulty interface lies between the chair and the keyboard.
 
Thanks vbSun!

I used your data control trick to get the connection string just right, then deleted the control.

Thanks alot. John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top