Witam wszystkich,
Mam problem zwiazny z usuwaniem rekordu w tabeli bazy danych SQL,
Mianowicie chodzi mi o poprawnośc polecenia sql ...
Wg mnie powinno usuwac ale tego nie robi i nie umiem znaleŹĆ przyczyny dlaczego tak jest :(
oto fragment kodu :
connection2 = new System.Data.SqlClient.SqlConnection();
connection2.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Database1.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
connection2.Open();
string command = "DELETE FROM tblUser WHERE ID = @ID ";
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(command, connection2);
cmd.CommandType = CommandType.Text;
cmd.Parameters.Add("@login", SqlDbType.VarChar, 100);
cmd.Parameters["@login"].Value = textBox1.Text;
cmd.Parameters.Add("@passwrod", SqlDbType.VarChar, 8000);
cmd.Parameters["@passwrod"].Value = textBox2.Text;
cmd.Parameters.Add("@ID", SqlDbType.Int, 100);
string id;
id = textBox3.Text;
int id2 = ds1.Tables["User"].Rows.Count;
id2++;
cmd.Parameters["@ID"].Value = id2;
cmd.Parameters.Add("@time", SqlDbType.Int, 100);
string time = textBox4.Text;
int time2 = Convert.ToInt32(time);
cmd.Parameters["@time"].Value = time2;
cmd.Parameters.Add("@points", SqlDbType.Int, 100);
string points = textBox5.Text;
int points2 = Convert.ToInt32(points);
cmd.Parameters["@points"].Value = points2;
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
MessageBox.Show("Delete");
connection2.Close();
I jak poprawnie usunac wszystkie pola tzn : login , password, etc..
pozdrawiam i dziekuje za pomoc :>