P
Ploobers
I've been searching around to figure out how to access a SQL Server
table programatically. I am very familiar with ADODB, but I have never
used it in Word VBA before. All I need to do is figure out how to open
the connection so I can access records and I can handle the rest. This
is some sample code I've used that I found elsewhere, but no matter
what I put it, it hangs up on the declaration of setting up ADODB
connections, making a Workspace. VBA doesn't even show ADODB as a
valid object. How can I connect? Thanks in advance!
'Dim odbc As Workspace
'Dim sql As Connection
'Dim connectStr As String
'connectStr = "ODBC;DRIVER={SQL Server};" + _
"SERVER=servername;" + _
"DATABASE=database name;" + _
"UID=username;" + _
"PWD=password;" + _
"LOGINTIMEOUT=5;"
'Set odbc = CreateWorkspace("Test Sql", "username", "password",
dbUseODBC)
'Set sql = odbc.OpenConnection("TestSql", dbDriverCompleteRequired,
True, _
connectStr)
' Do work
' sql.Close
'odbc.Close
table programatically. I am very familiar with ADODB, but I have never
used it in Word VBA before. All I need to do is figure out how to open
the connection so I can access records and I can handle the rest. This
is some sample code I've used that I found elsewhere, but no matter
what I put it, it hangs up on the declaration of setting up ADODB
connections, making a Workspace. VBA doesn't even show ADODB as a
valid object. How can I connect? Thanks in advance!
'Dim odbc As Workspace
'Dim sql As Connection
'Dim connectStr As String
'connectStr = "ODBC;DRIVER={SQL Server};" + _
"SERVER=servername;" + _
"DATABASE=database name;" + _
"UID=username;" + _
"PWD=password;" + _
"LOGINTIMEOUT=5;"
'Set odbc = CreateWorkspace("Test Sql", "username", "password",
dbUseODBC)
'Set sql = odbc.OpenConnection("TestSql", dbDriverCompleteRequired,
True, _
connectStr)
' Do work
' sql.Close
'odbc.Close