Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all articles
Browse latest Browse all 3509

Use auto generate key

$
0
0

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?

 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); } 

I got Error:

"Cannot insert explicit value for identity column in table 'Member' when IDENTITY_INSERT is set to OFF."

Actually I shouldn't insert any value for first argument because it's auto generated. but this error appear after using this style:

protectedvoidButton1_Click(object sender,EventArgs e){newDataSet1TableAdapters.MemberTableAdapter().Insert(TextBox5.Text,TextBox6.Text,int.Parse(TextBox8.Text),TextBox9.Text,TextBox10.Text);}

And I get:

Error:No overload for method insert take 5 argument

So how should I solve this problem?

I have set

Is identity

to yes already.

</div> </div>


Viewing all articles
Browse latest Browse all 3509

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>