I'm trying to Select * from tbl1 and insert it into tbl1_DEL. Basically if user wants to delete a record, i will first insert it into _DEL table before I delete the actual record in case it was done in error. Here's my code so far...
queryD = "Insert Into tbl1_DEL "
queryD = queryD & " SELECT * from Tbl1 WHERE IdClient = @IdClient"
cmd.CommandText = queryD
cmd.Connection = Conn
cmd.Parameters.Add("@IDClient", SqlDbType.NChar).Value = 17 'Just testing here with hardcoded IDClient
rowAffected = cmd.ExecuteNonQuery()
if rowAffected <>0 then
Delete * from Tbl1 where IDClient = 17 'parametized as it is with the Insert/Select above
Column name or number of supplied values does not match table
I suspect the structures of tbl1_DEL and Tbl1 are different.
Either sync the structures or specify the field list (recommended)
Insert into tbl1_DEL (Fld1,Fld2...) Select Fld1,Fld2... From Tbl1 Where dClient = @IdClient
Per your comment
Insert into tbl1_DEL Select *,TheOtherField = GetDate() -- Assuming the one extra field is the last From Tbl1 Where dClient = @IdClient