A
acs68
Hi all,
Hoping someone can answer a couple of questions for me. I have found some
code on the Microsoft website to set up dsnless connections. I've inserted
the code below. I am at a bit of a loss as to when to use the code. I have
10 tables that I would like to attach to.
At what point do I run the code - only once ? or each time the database
loads ?
If anyine could explain this to me I'd really appreciate it.
Also, is it possible to simply create the ODBC connection via code and have
it automatically appear in the ODBC Administrator (in Control Panel).
thanks in advance,
A
dam
------START CODE------
Private Sub Form_Load()
MousePointer = vbHourglass
Dim strConnect As String
' Change the next line to reflect your driver and server.
strConnect = "driver={SQL Server};server=jonfo5;" & _
"database=pubs;Username=<username>;PWD=<strong password>;"
Set en = rdoEngine.rdoEnvironments(0)
Set cn = en.OpenConnection( _
dsName:="", _
Prompt:=rdDriverNoPrompt, _
ReadOnly:=False, _
Connect:=strConnect)
cn.QueryTimeout = 600
MousePointer = vbNormal
End Sub
Private Sub Command1_Click()
MousePointer = vbHourglass
Dim rs As rdoResultset
Set rs = cn.OpenResultset(NAME:="Select * from authors", _
Type:=rdOpenForwardOnly, _
LockType:=rdConcurReadOnly, _
Options:=rdExecDirect)
Debug.Print rs(0), rs(1), rs(2)
MousePointer = vbNormal
End Sub
-----------END CODE_--------------------
Hoping someone can answer a couple of questions for me. I have found some
code on the Microsoft website to set up dsnless connections. I've inserted
the code below. I am at a bit of a loss as to when to use the code. I have
10 tables that I would like to attach to.
At what point do I run the code - only once ? or each time the database
loads ?
If anyine could explain this to me I'd really appreciate it.
Also, is it possible to simply create the ODBC connection via code and have
it automatically appear in the ODBC Administrator (in Control Panel).
thanks in advance,
A
dam
------START CODE------
Private Sub Form_Load()
MousePointer = vbHourglass
Dim strConnect As String
' Change the next line to reflect your driver and server.
strConnect = "driver={SQL Server};server=jonfo5;" & _
"database=pubs;Username=<username>;PWD=<strong password>;"
Set en = rdoEngine.rdoEnvironments(0)
Set cn = en.OpenConnection( _
dsName:="", _
Prompt:=rdDriverNoPrompt, _
ReadOnly:=False, _
Connect:=strConnect)
cn.QueryTimeout = 600
MousePointer = vbNormal
End Sub
Private Sub Command1_Click()
MousePointer = vbHourglass
Dim rs As rdoResultset
Set rs = cn.OpenResultset(NAME:="Select * from authors", _
Type:=rdOpenForwardOnly, _
LockType:=rdConcurReadOnly, _
Options:=rdExecDirect)
Debug.Print rs(0), rs(1), rs(2)
MousePointer = vbNormal
End Sub
-----------END CODE_--------------------