Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ExecuteReader (C#)

418213Jan 2 2009 — edited Jan 7 2009
Hi,

I have got such problem with the following bold line!

Unable to load the form:
ORA-00936: missing expression

OleDbCommand cmd;
OleDbDataReader reader;

cmd = new OleDbCommand("select "
+ "USER_NAME,"
...
+ "LAST_LOGIN_DT from user_master where user_id=@par_id", conn);
this.tb_user_id.Text = ret_val.ToString();
cmd.Parameters.AddWithValue("@par_id", SqlDbType.Int).Value = this.tb_user_id.Text;

cmd.Connection.Open();
reader = cmd.ExecuteReader();
while (reader.Read())
{
this.tb_user_nm.Text = reader["USER_NAME"].ToString();
...
}
cmd.Connection.Close();

I actually do not have any problems to retrieve something in this way

OleDbConnection conn = new OleDbConnection("SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=my_pc)(PORT=1522))(CONNECT_DATA=(SERVICE_NAME=XE)));Provider=SQLOLEDB;User ID=abc_schema;Password=wsabc;");
int ret_val = 0;

try
{
conn.Open();
OleDbCommand cmd = new OleDbCommand("SELECT max(user_id) FROM user_master", conn);
ret_val = Convert.ToInt32(cmd.ExecuteScalar());
}
catch (System.Data.SqlClient.SqlException ex)
{
string msg = "Unable to retrieve the ID: ";
msg += ex.Message;
throw new Exception(msg);
}
finally
{
conn.Close();
}

I'm running Visual C# (2008) against an Oracle 10g Express DB.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 4 2009
Added on Jan 2 2009
5 comments
3,202 views