not able to save data getting error

master_2013

Active member
Joined
Jul 8, 2013
Messages
41
Programming Experience
Beginner
Untitled3.jpgUntitled4.jpgwhen i execute this code to save data i got data type mismatch in criteria expression when i remove the brackets used in like rs = "INSERT INTO [Duty Slip] VALUES(@ID,@DDate,@VehicleType,@RegNo,@Vehiclebookedfor,@Vehiclebookedby,@VisitPlace,@JourneyDate,@JourneyTime,@StartingReadingKM,@ReturnDate,@ReturnTime,@EndingReadingKM,@ACORNON-AC,@TotalKM,@Useddays,@NightHalt,@Hours,@AdvByClientsForCash,@ForFuel,@AdvByAgencyForCash,@ForFuel1)" then i got this error "NO VALUE GIVEN FOR ONE OR MORE REQUIRED PARAMETER" what to do please help me out ???

here is my code

Private Sub KryptonButton1_Click(sender As System.Object, e As System.EventArgs) Handles KryptonButton1.Click
If con.State = ConnectionState.Open Then
con.Close()
End If


Dim rs As String


Try
rs = "INSERT INTO [Duty Slip] VALUES('@ID','@DDate','@VehicleType','@RegNo','@Vehiclebookedfor','@Vehiclebookedby','@VisitPlace','@JourneyDate','@JourneyTime','@StartingReadingKM','@ReturnDate','@ReturnTime','@EndingReadingKM','@ACORNON-AC','@TotalKM','@Useddays','@NightHalt','@Hours','@AdvByClientsForCash','@ForFuel','@AdvByAgencyForCash','@ForFuel1')"
Dim cmd As OleDbCommand = New OleDbCommand(rs, con)
cmd.Parameters.AddWithValue("ID", KryptonTextBox18.Text)
cmd.Parameters.AddWithValue("DDate", KryptonLabel2.Text)
cmd.Parameters.AddWithValue("VehicleType", KryptonComboBox1.Text)
cmd.Parameters.AddWithValue("RegNo", KryptonTextBox16.Text)
cmd.Parameters.AddWithValue("Vehiclebookedfor", KryptonTextBox1.Text)
cmd.Parameters.AddWithValue("VehiclebookedBy", KryptonTextBox17.Text)
cmd.Parameters.AddWithValue("VisitPlace", KryptonTextBox2.Text)
cmd.Parameters.AddWithValue("JourneyDate", KryptonDateTimePicker1.Text)
cmd.Parameters.AddWithValue("JourneyTime", KryptonTextBox3.Text)
cmd.Parameters.AddWithValue("StartingReadingKM", KryptonTextBox4.Text)
cmd.Parameters.AddWithValue("ReturnDate", KryptonDateTimePicker2.Text)
cmd.Parameters.AddWithValue("ReturnTime", KryptonTextBox6.Text)
cmd.Parameters.AddWithValue("EndingReadingKM", KryptonTextBox5.Text)
cmd.Parameters.AddWithValue("ACORNON-AC", KryptonTextBox7.Text)
cmd.Parameters.AddWithValue("TotalKM", KryptonTextBox8.Text)
cmd.Parameters.AddWithValue("Useddays", KryptonTextBox9.Text)
cmd.Parameters.AddWithValue("NightHalt", KryptonTextBox10.Text)
cmd.Parameters.AddWithValue("Hours", KryptonTextBox11.Text)
cmd.Parameters.AddWithValue("AdvByClientsForCash", KryptonTextBox12.Text)
cmd.Parameters.AddWithValue("ForFuel", KryptonTextBox13.Text)
cmd.Parameters.AddWithValue("AdvByAgencyForCash", KryptonTextBox14.Text)
cmd.Parameters.AddWithValue("ForFuel1", KryptonTextBox15.Text)
con.Open()
Dim x As Integer = cmd.ExecuteNonQuery
MessageBox.Show(x.ToString & "Data Saved Successfully....")
KryptonButton5.Enabled = True
con.Close()
clear()
Catch ex As Exception
MsgBox(ex.Message)
End Try


End Sub
 
If the question you asked about here has been answered then please mark the thread Answered. If you have a new question then please start a new thread for that question.
 
Back
Top