こんにちは、更新ボタンを押すたびに追加し続ける問題があります:/どうすればそれを防ぐことができますか? これを理解するのに2日目でしたが、失敗しました:(
protected void Button1_Click(object sender, EventArgs e)
{
//Instantiate the connection with the database
using (SqlConnection myConnection = new SqlConnection("user id=username;" +
"password=password;" +
"trusted_connection=yes;" +
"database=DataBaseConnection;" +
"connection timeout=30;"))
{
//Open the Connection object
myConnection.Open();
//Instantiate a SQL Command with an INSERT query
SqlCommand myCommand = new SqlCommand("INSERT INTO BasicInfo (Firstname,Surname) Values(@a,@b);", myConnection);
if (TextBox1.Text !=null && TextBox2.Text != null)
{
//Texbox
myCommand.Parameters.AddWithValue("@a", TextBox1.Text);
myCommand.Parameters.AddWithValue("@b", TextBox2.Text);
//Execute the query
myCommand.ExecuteNonQuery();
}
else
{
//Code HEre?
}