Using A2K and adp. Is it necessary to open a connection (to SQL
Server 2000) everytime you call a stored procedure or open a
recordset? Or will opening a connection one time do, like at
Form_Open?
I have a number of combo boxes that call the following public sub when
the NotInList event is fired:
Public Sub InsertItem(strCommandText As String, strParameterName As
String, _
adType As DataTypeEnum, lngSize As Long, strNewData As String)
On Error GoTo InsertItem_Error
Dim cmdInsert As ADODB.Command
Dim prm As Parameter
Const conQuote = """"
Set cnn = New ADODB.Connection
cnn.ConnectionString = GetConnectString
cnn.Open
Set cmdInsert = New ADODB.Command
With cmdInsert
Set .ActiveConnection = cnn
.CommandType = adCmdStoredProc
.CommandText = conQuote & strCommandText & conQuote
End With
Set prm = _
cmdInsert.CreateParameter(strParameterName, adType,
adParamInput, lngSize, strNewData)
cmdInsert.Parameters.Append prm
cmdInsert.Execute
Set cnn = Nothing
Exit Sub
....<error processing snipped>...
I set the connection, call the stored procedure, then close the
connection. I open recordsets in other parts of the form as
well...opening and closing the connection. Is it necessary to make
all these connections or can I just make one at Form_Open and close it
at Form_Close?