Sunday, October 22, 2006

ACCESS: ExecuteNonQuery

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim conn As OleDbConnection = Nothing
Dim cmd As OleDbCommand = Nothing
Dim sql As String = Nothing
Dim ConnectionString As String = Nothing

ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\BD_EMP.mdb"

conn = New OleDbConnection()
conn.ConnectionString = ConnectionString
conn.Open()

sql = "INSERT INTO CLIENTS(ID_CLIENT) VALUES ('ID_10') "
cmd = New OleDbCommand(sql, conn)

Try
cmd.ExecuteNonQuery()
Catch ae As OleDbException
MessageBox.Show(ae.Message.ToString())
Finally
conn.Close()
End Try
End Sub

0 Comments:

Post a Comment

<< Home