hi there,
any one know why this code wont work for inserting a new record???
as you can tell i am fairly new to this so help greatfully appricated...
any one know why this code wont work for inserting a new record???
VB.NET:
Private Sub save_calendar_details()
If txtPersonID.Text = "" Then
Dim connetionString As String
Dim oledbCnn As OleDbConnection
Dim oledbCmd As OleDbCommand
Dim sql As String
'todo set password and user for database
connetionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=H:\My Pictures\hotel_db.mdb;User Id=admin;Password=;"
sql = "INSERT INTO tbl_calendar values(" & (txtCalendarID.Text) & ",'" & DateTimePicker1.Value & "','" & DateTimePicker1.Value & "')"
oledbCnn = New OleDbConnection(connetionString)
Try
'open and prepare connection
oledbCnn.Open()
oledbCmd = New OleDbCommand(sql, oledbCnn)
Dim oledbReader As OleDbDataReader = oledbCmd.ExecuteReader()
oledbReader.Close()
oledbCmd.Dispose()
oledbCnn.Close()
Catch ex As Exception
'get error message
MsgBox(ex.GetType.Name & " : " & ex.Message)
End Try
End If
End Sub
as you can tell i am fairly new to this so help greatfully appricated...