|
|
|
|
|
Dicas
|
|
Visual Basic (Banco de Dados)
|
|
|
Título da Dica: Passar parametro para SQL armazenada em DB - ADO
|
|
|
|
Postada em 8/10/2000 por Webmaster
webmaster@vbweb.com.br
Sub ADOExecuteParamQuery() Dim cnn As New ADODB.Connection Dim cat As New ADOX.Catalog Dim cmd As ADODB.Command Dim rst As New ADODB.Recordset Dim fld As ADODB.Field 'Open the connection cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\nwind.mdb;"
'Open the catalog cat.ActiveConnection = cnn
'Get the Command object from the Procedure Set cmd = cat.Procedures("Sales by Year").Command
'Specify the parameter values cmd.Parameters("Forms!Sales by Year Dialog!" & _ "BeginningDate")=#8/1/1993# cmd.Parameters("Forms!Sales by Year Dialog!" & _ "EndingDate")=#8/31/1993# 'Open the recordset rst.Open cmd, , adOpenForwardOnly, adLockReadOnly, adCmdStoredProc
'Display the records in the debug window While Not rst.EOF For Each fld In rst.Fields Debug.Print fld.Value & ";"; Next Debug.Print rst.MoveNext Wend
'Close the recordset rst.Close
'Apesar da documentação não fazê-lo, *EU acrescento*... '(chato 8^)) né?) Set rst = Nothing cmd.Close Set cmd = Nothing
'cat.Close '<< Não achei no Doc, referência ao .Close Set cat = Nothing '<< Só ACHEI Nothing cnn.Close Set cnn = Nothing 'Fim do *EU Acrescento* End Sub
|
|
|
|
|