Insert query در سی شارپ
I'm having an issue at the moment which I am trying to fix. I just tried to access a database and insert some values with the help of C#The things I tried (worked)String query = "INSERT INTO dbo.SMS_PW (id,username,password,email) VALUES ('abc', 'abc', 'abc', 'abc')";
A new line was inserted and everything worked fine, now I tried to insert a row using variables:String query = "INSERT INTO dbo.SMS_PW (id,username,password,email) VALUES (@id, @username, @password, @email)";
command.Parameters.AddWithValue("@id","abc")
command.Parameters.AddWithValue("@username","abc")
command.Parameters.AddWithValue("@password","abc")
command.Parameters.AddWithValue("@email","abc")
command.ExecuteNonQuery();
Didn't work, no values were inserted. I tried one more thingcommand.Parameters.AddWithValue("@id", SqlDbType.NChar);
command.Parameters["@id"].Value = "abc";
command.Parameters.AddWithValue("@username", SqlDbType.NChar);
command.Parameters["@username"].Value = "abc";
command.Parameters.AddWithValue("@password", SqlDbType.NChar);...
تاریخ 10 اسفند 1399