I write a statement for updating details belongs to primary key(Mobile). but it is working only for other columns. when i update mobile number. it doesn't change.
Here the my query
private void button4_Click(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = new SqlCommand(@"UPDATE [dbo].[Table]
SET [First] = '"+textBox1.Text+"',[Last] = '"+textBox2.Text+ "' ,[Mobile] = '" +textBox3.Text+ "' ,[Email] = '" +textBox4.Text+ "' ,[Category] = '" + comboBox1.Text + "' WHERE (Mobile='" + textBox3.Text + "')", con);
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Updated Successfully");
display();
}
These following columns can be updated
First,
Last,
Email,
Category
but Mobile
column cannot be updated.
CREATE TABLE [dbo].[Table]
(
[First] VARCHAR(50) NOT NULL ,
[Last] VARCHAR(50) NOT NULL,
[Mobile] VARCHAR(50) NOT NULL,
[Email] VARCHAR(50) NOT NULL,
[Category] VARCHAR(50) NOT NULL,
CONSTRAINT [PK_Table] PRIMARY KEY ([Mobile])
)
Could anybody tell me the error?