How-To: Create and Execute a Command |
|
The ADO library provides the Command object that you can use to perform any of the usual operations such as selecting rows, adding a new record, or editing existing records. Consider the following table: You can use a Command object to create or add a new record to it. Here is an example of creating and executing a command: Private Sub cmdNewVideo_Click() Dim rstVideos As ADODB.Recordset Dim cmdVideos As ADODB.Command Set rstVideos = New ADODB.Recordset Set cmdVideos = New ADODB.Command cmdVideos.CommandText = "INSERT INTO Videos(Title, Director, " & _ "CopyrightYear, Length, Rating) " & _ "VALUES('Congo', 'Frank Marshall', 1995, " & _ "'109 Minutes', 'PG-13');" cmdVideos.CommandType = adCmdText cmdVideos.ActiveConnection = CurrentProject.Connection Set rstVideos = cmdVideos.Execute Set rstVideos = Nothing Set cmdVideos = Nothing End Sub
|
|
||
Home | Copyright © 2005-2016, FunctionX | |
|