ExecuteReader (C#)
418213Jan 2 2009 — edited Jan 7 2009Hi,
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.