Friday, 6 September 2013

SQL Server database : Change Table Value from texbox

SQL Server database : Change Table Value from texbox

I want to change the value of a column in a SQL Server table from filtered
by 2 others columns. But it returns error: Incorrect syntax ",". Here is
code:
private void button1_Click(object sender, EventArgs e)
{
string connectionString = @"Data Source=" +
System.IO.File.ReadAllText("Server.ini") + ";" + "Initial
Catalog=" + "lin2world" + ";" + "User ID=" +
System.IO.File.ReadAllText("User.ini") + ";" + "Password=" +
System.IO.File.ReadAllText("Password.ini");
string sql = "UPDATE user_item SET amount='" + textBox3.Text +
"'WHERE char_id='" + textBox1.Text + "' ,item_type='" +
textBox2.Text + "' ";
SqlConnection connection = new SqlConnection(connectionString);
SqlDataAdapter dataadapter = new SqlDataAdapter(sql, connection);
DataSet ds = new DataSet();
connection.Open();
dataadapter.Fill(ds, "user_item");
connection.Close();
MessageBox.Show("Item Amount Changed");
}
Thank you!

No comments:

Post a Comment