私は挿入ユーザー用のページを作成します。PRIMARY KEY制約 'PK__tblmembe__DD7012648BA5EC8B'の違反。データベースに挿入するとき*** ASP.Netクエリ
しかし、私は、ページを実行する私は、このエラーが表示さ
ASPコード
protected void Page_Load(object sender, EventArgs e)
{
System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection();
con.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["shopDBConnectionString"].ConnectionString;
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
cmd.CommandText = "insert into tblmember values ('" + txtemail.Text + "','" + txtname.Text + "','" + txtfamily.Text + "','" + txtpass.Text + "','','" + DropDownList1.SelectedValue + "') ";
cmd.CommandType = System.Data.CommandType.Text;
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
Response.Redirect("Default.aspx");
}
明らかに、重複する値をプライマリキーの列に挿入しています。 –
重複するエントリをデータテーブルの主キー列に挿入しようとしていますか? –
テーブルのプライマリキーとは何ですか? – user3185569