Hi,
I have problem with my simple program. Actually, I try to store date value in form of date format (mm/dd/yyyy). I got message that inform me "number of query values and destination fields are not the same". I provide example coding below to help you all understand. Please help me, it urgent....
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click
Dim oConn As New OleDbConnection ("Provider=Micr osoft.Jet.OleDb .4.0; Data Source=" & "C:\Documen ts and Settings\Crazy_ Frog\My Documents\Visua l Studio Projects\SportP lanet1\Data\spD ata.mdb")
Dim oApt As New OleDbDataAdapte r("SELECT [tbl_name] FROM [database_name]", oConn)
Dim sql As String = String.Empty
Try
If _id = 0 Then
sql = "INSERT INTO [database_name] Values('" & TextBox4.Text & "')"
End If
oConn.Open()
Dim oComm As New OleDbCommand(sq l, oConn)
oComm.ExecuteNo nQuery()
oConn.Close()
MsgBox("Data Save.")
Catch ex As Exception
MsgBox(ex.Messa ge)
End Try
End Sub
I have problem with my simple program. Actually, I try to store date value in form of date format (mm/dd/yyyy). I got message that inform me "number of query values and destination fields are not the same". I provide example coding below to help you all understand. Please help me, it urgent....
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click
Dim oConn As New OleDbConnection ("Provider=Micr osoft.Jet.OleDb .4.0; Data Source=" & "C:\Documen ts and Settings\Crazy_ Frog\My Documents\Visua l Studio Projects\SportP lanet1\Data\spD ata.mdb")
Dim oApt As New OleDbDataAdapte r("SELECT [tbl_name] FROM [database_name]", oConn)
Dim sql As String = String.Empty
Try
If _id = 0 Then
sql = "INSERT INTO [database_name] Values('" & TextBox4.Text & "')"
End If
oConn.Open()
Dim oComm As New OleDbCommand(sq l, oConn)
oComm.ExecuteNo nQuery()
oConn.Close()
MsgBox("Data Save.")
Catch ex As Exception
MsgBox(ex.Messa ge)
End Try
End Sub
Comment