I try to connect to oracle 11g but I have problem and receive the below error.the error show I must have problem in my sql syntax but I run it in oracle sql developer.the query is right
Please help me to solve this problem
Thanks.
try {
string oradb = "Data Source=(DESCRIPTION="
+ "(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=xxx-PC)(PORT=1521)))"
+ "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));"
+ "User Id=xxxx;Password=123456;";
OracleConnection con = new OracleConnection();
con.ConnectionString = oradb;
//String command = "Select Object_name,status from object_name where object_type='" + object_typeCB.SelectedText + "'";
string command = "select column1,column2,column3 from table1;";
OracleDataAdapter oda = new OracleDataAdapter();
oda.SelectCommand = new OracleCommand();
oda.SelectCommand.Connection = con;
oda.SelectCommand.CommandText = command;
con.Open();
oda.SelectCommand.ExecuteNonQuery();
DataSet ds = new DataSet();
oda.Fill(ds);
dataGridView1.DataSource = ds;
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString()+Environment.NewLine+ ex.StackTrace.ToString());
}
Error:
ORA-00911: invalid character
at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck)
at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, String procedure, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, Boolean bCheck)
at Oracle.DataAccess.Client.OracleCommand.ExecuteNonQuery()
at FileChecker.dropFrame.applyBt_Click(Object sender, EventArgs e) in C:\Users\rima\Documents\Visual Studio 2008\Projects\FileChecker\FileChecker\DropFrame.cs:line 61
Lose the ;
from the end of your SQL query