Hello,
I have a table with 8 colons and I want to update this colons. My codes are below,
Firstly codes was working normally and there was no prolem with UPDATE reqests. Then, I add "RETRY"(int) column to database and I want to update this column too. So I add the "RETRY" informations below, with bold font. I want to increase this row's value 1. But it isnt update to DB. I try lots of codes but it doesnt work. Could you please help me where I was wrong?
Regards.
---------------------------------
string updateQueueSQL = "UPDATE ds_info SET OKUNDU = @OKUNDU, RESPONSE = @RESPONSE, RETRY = @RETRY, DATE = GETDATE() WHERE ID = @ID";
SqlDataAdapter queueAdapter = new SqlDataAdapter(selectQueueSQL, dbConn);
// Initialize the SqlCommand object that will be used as the DataAdapter's UpdateCommand
SqlCommand queueUpdateCmd = new SqlCommand(updateQueueSQL, dbConn);
// Create and append the parameters for the Update command
queueUpdateCmd.Parameters.Add(new SqlParameter("@OKUNDU", SqlDbType.NVarChar, 1));
queueUpdateCmd.Parameters["@OKUNDU"].SourceVersion = DataRowVersion.Current;
queueUpdateCmd.Parameters["@OKUNDU"].SourceColumn = "OKUNDU";
queueUpdateCmd.Parameters.Add(new SqlParameter("@RESPONSE", SqlDbType.NVarChar, 200));
queueUpdateCmd.Parameters["@RESPONSE"].SourceVersion = DataRowVersion.Current;
queueUpdateCmd.Parameters["@RESPONSE"].SourceColumn = "RESPONSE";
queueUpdateCmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int));
queueUpdateCmd.Parameters["@ID"].SourceVersion = DataRowVersion.Original;
queueUpdateCmd.Parameters["@ID"].SourceColumn = "ID";
queueUpdateCmd.Parameters.Add(new SqlParameter("@RETRY", SqlDbType.Int));
queueUpdateCmd.Parameters["@RETRY"].SourceVersion = DataRowVersion.Original;
queueUpdateCmd.Parameters["@RETRY"].SourceColumn = "RETRY";
// Assign the SqlCommand to the UpdateCommand property of the SqlDataAdapter
queueAdapter.UpdateCommand = queueUpdateCmd;
// Create the DataSet.
DataSet queueDS = new DataSet("ds_info");
// Populate the dataset by running the Fill method of the SqlDataAdapter
queueAdapter.Fill(queueDS);
foreach (DataRow row in queueDS.Tables[0].Rows)
{
if (String.Empty == "")
{
row["OKUNDU"] = "E";
}
else
{
row["RETRY"] = int.Parse(row["RETRY"].ToString()) + 1;
//try 3 times
if (row["RETRY"].ToString() == "3")
{
row["OKUNDU"] = "E";
}
queueAdapter.Update(queueDS);
}
------------------------------------