I have this code and um tryng to add records but its giving me an error can you help please...
Public connstring As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\ven\oledb.accdb"
Public conn As New OleDbConnection
Private Sub clients_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
conn.ConnectionString = connstring
If conn.State = ConnectionState.Closed Then
conn.Open()
MsgBox("Open")
Else
MsgBox("Close")
End If
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Try
Dim sqlquery As String = "INSERT INTO `clients` (`Company Name`, `Company Address`, `Company Telephone`, `Contact Person`, `Person Tel`, `Email Address`, `Date Captured`) VALUES ('" & Company_NameTextBox.Text & _
"','" & Company_AddressTextBox.Text & _
"','" & Company_TelephoneTextBox.Text & _
"','" & Contact_PersonTextBox.Text & _
"','" & Person_TelTextBox.Text & _
"','" & Email_AddressTextBox.Text & _
"','" & Date_CapturedDateTimePicker.Text & "')"
Dim sqlcommand As New OleDbCommand
With sqlcommand
.CommandText = sqlquery
.Connection = conn
.ExecuteNonQuery()
End With
MsgBox("Record Added")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
- Add new comment
- 2 views