|
-
Aug 5th, 1999, 09:44 PM
#1
Thread Starter
New Member
I am trying to make my first connection to a SQL Server DB using ADO. I have simplified this code trying to find the error. But I get Runtime error “446” Object doesn’t support names arguments. I can enter almost the same code in for RDO and it runs fine. I am sure it is something very easy and/or stupid. Does anyone have any soloutions?
Dim cn As Connection
Dim rs As New ADODB.Recordset
Set cn = New Connection
cn.connectString = "driver={SQL Server};server = genisis_srv_1"
cn/open
-
Aug 6th, 1999, 12:05 AM
#2
Lively Member
this is some code that i found helpful from the wrox website, if you can download the information for the ado 2.1 book.
Hope this helps
Scott
Public g_objConn As ADODB.Connection ' connection object
Public g_strConn As String ' connection string
'
Public Sub ConnectionSetup()
'
' Shows connection strings for providers
' You should substitute the following:
'
' C:\Temp\pubs.mdb for you Access database
' Tigger for the name of your SQL Server
' pubs for the name of your SQL Server databse
' davids for the name of your SQL Server user
' abc123 for the name of your SQL Server password
'
' uncomment your connection string of choice
' odbc using DSN
' g_strConn = "DSB=adoperf"
'
' odbc using DSN-less - to Access
g_strConn = "Driver={Microsoft Access Driver (*.mdb)};" & _
" DBQ=adoperf.mdb"
' odbc using DSN-less - to SQL Server
'g_strConn = "Driver={SQL Server}; Server=server_name;" & _
" Database=database; UID=user; PWD=password"
' ' native Access provider
' g_strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
' " Data Source=D:\wrox\ADOPerf.mdb"
' ' native SQL Server provider
' g_strConn = "Provider=SQLOLEDB; Data Source=opentestserver;" & _
' "Initial Catalog=pubs; User Id=sa; Password="
End Sub
Public Sub ConnectionConnect(strConn As String)
' open the connection
Set g_objConn = New ADODB.Connection
g_objConn.Open strConn
End Sub
Public Sub ConnectionDisconnect()
' if the connection is open, close it
' only close if the connection variable is an object
If Not (g_objConn Is Nothing) Then
If g_objConn.State = adStateOpen Then
g_objConn.Close
End If
Set g_objConn = Nothing
End If
End Sub
-
Aug 6th, 1999, 12:12 AM
#3
Lively Member
shouldn't it be
oConn.ConnectionString "Driver={SQL Server}; Server-server_name;......" etc
vice
oConn.connectstring ...etc
?
Bash
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|