Hi All,
if have the following SQLCommand which should do an Update. The issue is, that I get no errors but it still do not update the database ?
SqlConnection sqlconn2 = new SqlConnection(this.connectionString);
sqlconn2.Open();
string strCmd = "UPDATE dbo.mydata SET WEB_OBEZ1 = @OBEZ1, WEB_OBEZ2 = @OBEZ2, WEB_OBEZ3 = @OBEZ3 WHERE O_KURZ = @OKURZ";
using (SqlCommand cmd2 = new SqlCommand(strCmd, sqlconn2))
{
cmd2.Parameters.Add("@OBEZ1", SqlDbType.NVarChar);
cmd2.Parameters.Add("@OBEZ2", SqlDbType.NVarChar);
cmd2.Parameters.Add("@OBEZ3", SqlDbType.NVarChar);
cmd2.Parameters.Add("@OKURZ", SqlDbType.NVarChar);
foreach (DataRow dr in dt.Rows)
{
// Felder holen
string okuerzel = dr["O_KURZ"].ToString();
string bezeichnung = dr["O_BEZ"].ToString();
string[] lines = CreateNewOrgBez(bezeichnung);
cmd2.Parameters["@OBEZ1"].Value = lines[0];
cmd2.Parameters["@OBEZ2"].Value = lines[1];
cmd2.Parameters["@OBEZ3"].Value = lines[2];
cmd2.Parameters["@OKURZ"].Value = okuerzel;
cmd2.ExecuteNonQuery();
}
}
sqlconn2.Close();