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")
Member Avatar for 1stDAN

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.