I am a VB beginner, I have been very troubled for this question. I finally wrote it out, and make progress with me beginners!
I use the ADO to connect to the database to display the contents of the qualified condition in the database by binding the DataGrid control.
Option expedition
PRIVATE SUB Command1_Click () DIM CN AS New AdoDb.Connection 'Database Connection Variable DIM CMD AS New AdoDb.command' Command DIM RS AS NEW AdoDb.Recordset 'Recording Set DIM STRCONNECT AS STRING' Connection String SET CN = New AdoDB. connection strConnect = "Provider = SQLOLEDB.1; Persist Security Info = False; User ID = sa; Initial Catalog = database; Data Source = servername" 'specify a connection string cn.ConnectionString = strConnect cn.Open' connected database With Cmd. ActiveConnection = CN .commandType = adcmdStoredProc 'has four optional types, using SQL Server stored in programming, is a good method. Commandtext = "sp_get_name"' stored procedure name .parameters.refresh .parameters ("@ dt "). value = date (value (only one parameter stored procedure)) 'the parameters stored during End With With rs .CursorLocation = adUseClient .CursorType = adOpenStatic .LockType = adLockReadOnly .Open Cmd End WithSet DataGrid1.DataSource = rs 'Binding Database Display Control
End Sub
To display data in the DataGrid control, it is indispensable to two statements that CursorLocation = ADuseClient and SET DataGrid1.dataSource = RS.