开发者

how to connecting to oracle database :(( [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
开发者_高级运维

This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.

Closed 8 years ago.

Improve this question

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜