Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
when i fire insert query,it display error mesage


SQL
adp = New SqlDataAdapter("insert into tbl1 values" & "(" & TextBox1.Text & "," & "'" & TextBox2.Text & "'" & ")", cn)
        adp1 = New SqlDataAdapter("insert into tbl2 values" & "(" & TextBox1.Text & "," & "'" & TextBox3.Text & "'" & "," & TextBox4.Text & ")", cn)
        cmd.ExecuteNonQuery()
        adp.Fill(ds, "tb1")
        cmd.ExecuteNonQuery()
        adp1.Fill(ds1, "tb2")
        MsgBox("Record Inserted....")


error message....
An explicit value for the identity column in table 'tbl1' can only be specified when a column list is used and IDENTITY_INSERT is ON.
Posted

1 solution

You need to specify column name Except Identity Clumn
like

SQL
INSERT INTO tbl1 (Name,Addess,Phone) Values ('Imdad','India','91')


Thanks,
Imdadhusen
 
Share this answer
 
Comments
[no name] 11-Feb-11 1:10am    
Good Call.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900