adding parameters to Oracle Oledb for update

M

Mo

Hi,

I am having a lot of problem adding a parameter to a oledb data sorce
and execute it here is what I have I call

string Pump="Yes"
ResultSet = RunQuery("Update CDB_on set Resultx=:Resultx where
(Serial_Number='" + row["Serial_Number"].ToString() + "') ", Pump,
"U");

in this procedure I have the following:
//--------------------------------------------------------------------------------------------------------------------------
public static DataSet RunQuery(String QueryString, string P1, string
cType)
{
String ConnectionString = MyConnectionString
OleDbConnection DBConnection = new
OleDbConnection(ConnectionString);
OleDbDataAdapter DBAdapter;
DataSet ResultsDataSet = new DataSet();
try
{
DBAdapter = new OleDbDataAdapter(QueryString,
DBConnection);
if (cType == "U")
{
OleDbCommand cmd = new OleDbCommand(QueryString,
DBConnection);
cmd.Parameters.Add("Html_Result",
OleDbType.Empty).Value = P1;
DBAdapter.UpdateCommand = cmd; //-----------Error
Here----------------------------
DBAdapter.Fill(ResultsDataSet);//-----------Error
Here----------------------------
DBConnection.Close();
return;

}
else
{
DBAdapter.Fill(ResultsDataSet);
DBConnection.Close();
}
}
catch (Exception ex)
{
if (DBConnection.State == ConnectionState.Open)
{
DBConnection.Close();
}
Console.WriteLine(ex.Message + "--" +
ex.StackTrace.ToString());

}
return ResultsDataSet;
}
}
what is the correct way of adding the parameters and executing it.

Thanks,
MO
 
B

Bjorn Abelli

...
I am having a lot of problem adding a parameter to a oledb data sorce
and execute it here is what I have I call

string Pump="Yes"
ResultSet = RunQuery("Update CDB_on set Resultx=:Resultx where
(Serial_Number='" + row["Serial_Number"].ToString() + "') ", Pump,
"U");

Above, you've named the parameter ":Resultx", but below you've named it
"Html_Result".

I believe that could be the problem.

cmd.Parameters.Add("Html_Result", OleDbType.Empty).Value = P1;

It would be easier to track what's wrong if you also provide the error
messages you get.


// Bjorn A
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top