1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cn As OleDbConnection
Dim cmd As OleDbCommand
'Dim dr As OleDbDataReader
'Dim icount As Integer
Dim str As String
' Try
cn = New OleDbConnection("provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\karim\Documents\Visual Studio 2010\Projects\bureau d'ordre\bureau d'ordre\bo.accdb")
cn.Open()
str = "insert into msgdept values(" & Label9.Text & "," & TextBox2.Text & "," & ComboBox1.Text & "," & RichTextBox1.Text & "," & ListBox1.Text & "," & Label3.Text & "," & TextBox3.Text & ")"
'string stores the command and CInt is used to convert number to string
cmd = New OleDbCommand(str, cn)
cmd.ExecuteNonQuery()
' MessageBox.Show(icount)
'displays number of records inserted
' Catch
' End Try
cn.Close()
MsgBox("OK")
End Sub |
Partager