i have a database with 16 fields and i just want to fill the first 7 fields.
i am using this command
"INSERT INTO products (SupplierID, catalogid, ccode,cname,oprice,cprice,pother2) VALUES (" & reader("SupplierID").ToString() & "," & reader("catalogid").ToString() & "," & reader("ccode").ToString() & "," & reader("cname").ToString() & "," & reader("oprice").ToString() & "," & reader("cprice").ToString() & "," & reader("pother2").ToString() & ")"
so any solutions?
There’s nothing wrong with only filling a subset of the available fields in a table as long as the columns that you are not filling are specified as nullable or have a default assigned (assuming SQL server).
However, there is something wrong with the way that you are building your command: you do not have quotes around what appear to be string values (i.e. ccname) nor are you safeguarding against SQL injection attacks.
It is much better to use a parameterized query.
Roughly, your code would look something like: