By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,336 Members | 1,293 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,336 IT Pros & Developers. It's quick & easy.

adding parameters to Oracle Oledb for update

P: n/a
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

Mar 30 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"Mo" wrote...
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
Mar 31 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.