使用macros连接到数据库

我试图打开一个新的连接使用macros但语句“Rcrdst.Open”给我运行时错误: “ORA-00911:无效的字符” 。 任何人都可以帮我find问题吗?

Dim C As Integer Dim ambiente As String Dim userid As String Dim Password As String Dim Query As String Dim Newsht As Worksheet Dim Conn As ADODB.Connection Dim Rcrdst As ADODB.Recordset Set Newsht = ActiveWorkbook.Sheets("sheet1") ambiente = InputBox("Please insert environement in which query has to be run.", "Test") userid = InputBox("Please insert your USER ID for " & ambiente & " environment.", "Test") Password = InputBox("Please insert the PASSWORD related to " & userid & " user.", "Test") If userid <> "" And Password <> "" Then Set Conn = New ADODB.Connection Conn.ConnectionString = "Provider=MSDAORA; Password= " & Password & ";User ID= " & userid & "; Data Source = " & ambiente & ";Persist Security Info=True" Conn.Open Query = "select seq_prenotazione, cod_rapporto,stato_pren from via.prenotazione where seq_prenotazione in (700016298527, 700016761977);" Set Rcrdst = New ADODB.Recordset Rcrdst.CursorLocation = adUseClient Rcrdst.CursorType = adOpenStatic Rcrdst.LockType = adLockBatchOptimistic Rcrdst.Open Query, conn 'code to work on data extracted end if Rcrdst.Close Conn.Close 

提前致谢

删除尾部; 从查询中。

有时你需要它,有时你不需要。 也许一个Oracle专家可以解释它。