No value given for one or more required parameters

Posted by Cibin under VB.NET on 5/16/2013 | Points: 10 | Views : 2602 | Status : [Member] | Replies : 2
Hi ,

am using visual studio 2010 with MS ACCESS ,, wen i try to insert values into the table,, i got this error,,, "No value given for one or more required parameters",,, But actually all fields have the values.. and also Some times it will work without any error,,,
Can anyone help me out Plzzzzzzzzzzzzzzzz,, Its little urgent,,

My Code is :

Dim dr As OleDb.OleDbDataReader
myOleDbConnection = New OleDb.OleDbConnection(c.con())
str = "SELECT Fileno,Name,MobileNo,Site,Division,Date1,Plans,Remarks,Category FROM Report WHERE Division='" & ComboBox1.Text & "'"

Dim cmd As New OleDb.OleDbCommand(str, myOleDbConnection)


dr = cmd.ExecuteReader()

If dr.HasRows = True Then

While dr.Read()
str1 = "INSERT INTO Rpt1 VALUES('" & dr.Item(0) & "','" & dr.Item(1) & "','" & dr.Item(2) & "','" & dr.Item(3) & "','" & dr.Item(4) & "','" & dr.Item(5) & "'," & dr.Item(6) & ",'" & dr.Item(7) & "','" & dr.Item(8) & "' )"
Dim cmd1 As New OleDb.OleDbCommand(str1, myOleDbConnection)

End While
End If


Dim obj As New Form18()



Posted by: Niladri.Biswas on: 5/16/2013 [Member] Platinum | Points: 25

Do a thing... print the parameter values for the success and failure cases and you will come to know the difference.

Best Regards,
Niladri Biswas

Cibin, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rasik on: 5/17/2013 [Member] Starter | Points: 25

While inserting record into a table, always specify the number of comma seperated columns into which values are to be inserted.
eg. INSERT INTO TableName (Column1, Column2, Column3) VALUES(@Column1, @Column2, @Column3)

In your case you need to provide values for all the columns (20 if table has 20 columns).

Try specifying column name and run one more time.

Cibin, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response