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);
                    conn.Open();
                    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;

comand.ExecuteNonQuery();

...
i don't finding statement error from program

best regards,
maartin

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.

conn.Open();

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.