i have promblem when using bottom update, when i get data in textbox, this is my code

string uSql;
uSql = "UPDATE Material SET MaterialName='"+txNama.Text+"',MatGroupID='"+cbGroup.Text+"' WHERE MaterialID='"+txKode.Text+"'";
SqlConnection conn = new SqlConnection(connetionString);

SqlCommand comand = new SqlCommand(uSql, conn);
                    comand.Parameters.Add(new SqlParameter("@MaterialName", SqlDbType.NVarChar, 50));
                    comand.Parameters["@MaterialName"].Value = txNama.Text;
                    comand.Parameters.Add(new SqlParameter("@MatGroupID", SqlDbType.NVarChar, 20));
                    comand.Parameters["@MatGroupID"].Value = cbGroup.Text;


i don't finding statement error from program

best regards,

Are You using query or stored procedure,all you created a query for update,so remove the parameters and put conn.open() on before of command creation.


SqlCommand comand = new SqlCommand(uSql, conn);

uSql = "UPDATE Material SET MaterialName=@MaterialName,MatGroupID=@MatGroupID WHERE MaterialID=@MaterialID";

Add a MaterialID parameter and try using the above query.