J
Jason
Hi,
Is the following code correct to call the ado-connection
from every form i create. I'm getting errors if i execute it.
For testing purposes i used the code in the form's module and then it
worked, but not how i like it. The purpose of it, is to use connection
pooling.
Here is the code in the module:
option explicit
Dim cnn As ADODB.Connection
public sub ado_conn()
Set cnn = New ADODB.Connection
With cnn
.Provider = "sqloledb"
.Properties("Data Source") = "local"
.Properties("Initial Catalog") = "NEW"
.Properties("User ID") = "sa"
.Properties("Password") = "password"
End With
end sub
From the form onOpen event:
dim cnn as adodb.connection
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.CursorLocation = adUseClient
cnn.Open cnn
cnn.usp_search 7, Nz(Null, ""), rst 'this line calls a stored procedure
from a sql server database.
Set Forms("Form1").Recordset = rst
rst.Close
Set rst = Nothing
cnn.Close
Set cnn = Nothing
Is the following code correct to call the ado-connection
from every form i create. I'm getting errors if i execute it.
For testing purposes i used the code in the form's module and then it
worked, but not how i like it. The purpose of it, is to use connection
pooling.
Here is the code in the module:
option explicit
Dim cnn As ADODB.Connection
public sub ado_conn()
Set cnn = New ADODB.Connection
With cnn
.Provider = "sqloledb"
.Properties("Data Source") = "local"
.Properties("Initial Catalog") = "NEW"
.Properties("User ID") = "sa"
.Properties("Password") = "password"
End With
end sub
From the form onOpen event:
dim cnn as adodb.connection
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.CursorLocation = adUseClient
cnn.Open cnn
cnn.usp_search 7, Nz(Null, ""), rst 'this line calls a stored procedure
from a sql server database.
Set Forms("Form1").Recordset = rst
rst.Close
Set rst = Nothing
cnn.Close
Set cnn = Nothing