0

hello friends
I have three tables with similer structure and same column name id,sname,ssno,grade.
I want to copy rows from table1 to table2 and table3 based on column grade . I am getting an error
No value given for one or more required parameters.
can someone kindly tell me how do i fix the error ?

sql

 "insert into table2(id,sname,ssno,grade) select id,sname,ssno,grade from table1 where grade =A"
 "insert into table3(id,sname,ssno,grade) select id,sname,ssno,grade from table1 where grade =B"

here is my full code

Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\dtb.accdb")
        Dim CmdStr As String
        CmdStr = "insert into table3(id,sname,ssno,grade) select id,sname,ssno,grade from table1 where grade =B"
        CmdStr = "insert into table2(id,sname,ssno,grade) select id,sname,ssno,grade from table1 where grade =A"

        con.Open()
        Dim cmd As OleDbCommand = New OleDbCommand(CmdStr, con)
        cmd.ExecuteNonQuery()
        con.Close()
        MsgBox("Done")
2
Contributors
1
Reply
14
Views
4 Years
Discussion Span
Last Post by 1stDAN
0

hi, this error message "No value given for one or more required parameters." tells you that the list "id,sname,ssno,grade" is incomplete, that is there are further necessary columuns missing. Missing columns usually have the option "not null" in your ddl create table statement, e.g. create tabele2 (id int not null, sname varchar(50), ssno int, grade double(5,2), subject varchar(20) NOT NULL ....).

You see, because subject (very important thing, hence NOT NULL:) is attributed NOT NULL, you cannot omit it from you insert list. So check your own create table2 statement.

Edited by 1stDAN

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.