Use auto generate key in asp.net

ruseller781

New Member
I have a field which is an auto generated primary key. Now I need to insert a row with this field as one of its column. How should I create "insert" arguments?\[code\] protected void Button1_Click(object sender, EventArgs e) { new DataSet1TableAdapters.MemberTableAdapter().Insert( 1,TextBox5.Text,TextBox6.Text, int.Parse(TextBox8.Text), TextBox9.Text, TextBox10.Text); } \[/code\]I got Error:\[code\]"Cannot insert explicit value for identity column in table 'Member' when IDENTITY_INSERT is set to OFF."\[/code\]Actually I shouldn't insert any value for first argument because it's auto generated. but this error appear after using this style:\[code\] protected void Button1_Click(object sender, EventArgs e) { new DataSet1TableAdapters.MemberTableAdapter().Insert( TextBox5.Text, TextBox6.Text, int.Parse(TextBox8.Text), TextBox9.Text, TextBox10.Text); }\[/code\]And I get:\[code\] Error:No overload for method insert take 5 argument\[/code\]So how should I solve this problem?
 
Back
Top