2016-12-15 10 views
1

Я использовал FirebirdClient 2.0 ADO.NET, и я перехожу к FirebirdClint версии 5.7 ADO.NET.FirebirdClient 5.7 ADO.NET UnknownStatement в fbScript.Parse()

Этот код ниже не работает в новой версии firebirdClient

If IO.File.Exists(pathScript) Then 
     txtScript.Close() 

     Dim fbScript As New FbScript(pathScript) 

     fbScript.Parse() 
     If fbScript.Results.Count = 0 Then 
      Exit Sub 
     End If 

     If fbScript.Results.Count > 0 Then 
      If automatico = False Then 
       frmImpSintegra.LblTitulo.Text = "Gravando 60I" 
      End If 
      Application.DoEvents() 

      Dim fbConn As New FbConnection(cnEmpresa) 
      fbConn.Open() 

      Dim fbBatch As New FirebirdSql.Data.Isql.FbBatchExecution(fbConn) 
      fbBatch.AppendSqlStatements(fbScript) 
      fbBatch.Execute(True) 
      fbConn.Close() 
     End If 

     deleteArquivoTemporario() 
     txtScript = New IO.StreamWriter(pathScript) 
    End If 

Эта ошибка появляется в строке fbScript.Parse()

Полный StackTrace за исключением:

Exception thrown: 'System.ArgumentException' in FirebirdSql.Data.FirebirdClient.dll 
System.Transactions Critical: 0 : <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Exceção não tratada</Description><AppDomain>Livros.vshost.exe</AppDomain><Exception><ExceptionType>System.ArgumentException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>The type of the SQL statement could not be determined. See also UnknownStatement event. 
Statement: c:\0556_16122016_081323.txt.</Message><StackTrace> em FirebirdSql.Data.Isql.FbScript.Parse() 
    em Livros.importacaoSintegra.grava60I(Boolean automatico) 
    em Livros.importacaoSintegra.importa60I(String linhaTexto, StreamWriter&amp;amp; txtScript, String diaEncerrado60, Boolean chkECF, Boolean automatico, String empresa, Boolean chkDiv60I, Boolean chkTruncar, String Impressoras, Boolean chkValida60I, Boolean chk60I75, Int32 contador) 
    em Livros.importacaoSintegra.importaSintegraAutomatico(String txtPasta, Boolean automatico, String empresa, String txtMesAno, Boolean Chk74, String txtDataInventario, String txtTipoEstoque, Boolean ChkExcluirRegistro, Boolean chkAtualizarQuantidade, Boolean chkEcf, Boolean chkNf, Boolean ChkAtualizaCodigoInterno, Boolean chkVerCfop, String Cnpj_Empresa1, Boolean chkValida60I, Boolean chkAliquotaReal, Boolean chkDiv60I, Boolean chkTruncar, Boolean chk60I75, String mes1, String ano1, String cnAtual1, String cnEmpresa1, String CnPrincipalEmpresa1, Int32 idArquivoSpe1, Boolean chkSo75) 
    em Livros.frmImpSintegra.btnConfirmarSinal_Click(Object sender, EventArgs e) 
    em System.Windows.Forms.Control.OnClick(EventArgs e) 
    em System.Windows.Forms.Button.OnClick(EventArgs e) 
    em System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) 
    em System.Windows.Forms.Control.WmMouseUp(Message&amp;amp; m, MouseButtons button, Int32 clicks) 
    em System.Windows.Forms.Control.WndProc(Message&amp;amp; m) 
    em System.Windows.Forms.ButtonBase.WndProc(Message&amp;amp; m) 
    em System.Windows.Forms.Button.WndProc(Message&amp;amp; m) 
    em System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp;amp; m) 
    em System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp;amp; m) 
    em System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 
    em System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&amp;amp; msg) 
    em System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) 
    em System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) 
    em System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) 
    em Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() 
    em Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() 
    em Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine) 
    em Livros.My.MyApplication.Main(String[] Args) 
    em System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) 
    em System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) 
    em Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 
    em System.Threading.ThreadHelper.ThreadStart_Context(Object state) 
    em System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
    em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
    em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
    em System.Threading.ThreadHelper.ThreadStart()</StackTrace><ExceptionString>System.ArgumentException: The type of the SQL statement could not be determined. See also UnknownStatement event. 
Statement: c:\0556_16122016_081323.txt. 
    em FirebirdSql.Data.Isql.FbScript.Parse() 
    em Livros.importacaoSintegra.grava60I(Boolean automatico) 
    em Livros.importacaoSintegra.importa60I(String linhaTexto, StreamWriter&amp;amp; txtScript, String diaEncerrado60, Boolean chkECF, Boolean automatico, String empresa, Boolean chkDiv60I, Boolean chkTruncar, String Impressoras, Boolean chkValida60I, Boolean chk60I75, Int32 contador) 
    em Livros.importacaoSintegra.importaSintegraAutomatico(String txtPasta, Boolean automatico, String empresa, String txtMesAno, Boolean Chk74, String txtDataInventario, String txtTipoEstoque, Boolean ChkExcluirRegistro, Boolean chkAtualizarQuantidade, Boolean chkEcf, Boolean chkNf, Boolean ChkAtualizaCodigoInterno, Boolean chkVerCfop, String Cnpj_Empresa1, Boolean chkValida60I, Boolean chkAliquotaReal, Boolean chkDiv60I, Boolean chkTruncar, Boolean chk60I75, String mes1, String ano1, String cnAtual1, String cnEmpresa1, String CnPrincipalEmpresa1, Int32 idArquivoSpe1, Boolean chkSo75) 
    em Livros.frmImpSintegra.btnConfirmarSinal_Click(Object sender, EventArgs e) 
    em System.Windows.Forms.Control.OnClick(EventArgs e) 
    em System.Windows.Forms.Button.OnClick(EventArgs e) 
    em System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) 
    em System.Windows.Forms.Control.WmMouseUp(Message&amp;amp; m, MouseButtons button, Int32 clicks) 
    em System.Windows.Forms.Control.WndProc(Message&amp;amp; m) 
    em System.Windows.Forms.ButtonBase.WndProc(Message&amp;amp; m) 
    em System.Windows.Forms.Button.WndProc(Message&amp;amp; m) 
    em System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp;amp; m) 
    em System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp;amp; m) 
    em System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 
    em System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&amp;amp; msg) 
    em System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) 
    em System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) 
    em System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) 
    em Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() 
    em Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() 
    em Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine) 
    em Livros.My.MyApplication.Main(String[] Args) 
    em System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) 
    em System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) 
    em Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 
    em System.Threading.ThreadHelper.ThreadStart_Context(Object state) 
    em System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
    em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
    em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
    em System.Threading.ThreadHelper.ThreadStart()</ExceptionString></Exception></TraceRecord> 

Мой файл txt:

INSERT INTO REGISTRO_60I12 (TIPO,SUBTIPO,DATA_EMISSAO,NUMERO_SERIE,MODELO,COO,ITEM,PRODUTO_SERVICO,QUANTIDADE,VALOR_LIQUIDO,BASE_CALCULO,ALIQUOTA_SUBSTITUICAO,VALOR_ICMS,MESANO,EMPRESA)VALUES('60','I','2016.12.09','BE090910100010004937','2D',320645,'001','12036',1.000,3.99,0.00,'F',0.00,122016,0556); 

Может кто-нибудь мне помочь?

+0

Не могли бы вы разместить полный стек исключения? –

+0

Я поставил свой вопрос в полный стек ... –

ответ

1

Вы передаете имя файла конструктору FbScript, но этот конструктор ожидает фактического содержимого скрипта. Это приводит к тому, что имя файла c:\0556_16122016_081323.txt анализируется, как если бы оно было выражением, а c:\0556_16122016_081323.txt не является известным выражением Firebird.

Вместо этого вы должны использовать FbScript.LoadFromFile(pathScript).

+0

@TiagoRoquedeCarvalho VB не мой язык, но, вероятно, что-то вроде 'Dim fbScript As FbScript', а затем' fbScript = FbScript.LoadFromFile (pathScript) ' –

+0

Я положил этот код:
'Dim fbScript As New fbScript (pathScript)' '
fbScript = FbScript.LoadFromFile (pathScript)' '
fbScript.Parse()'
его работы, но я не понимаю, как объявить fbScript иначе это путь:
'Dim fbScript As New FbScript (pathScript)' –

 Смежные вопросы

  • Нет связанных вопросов^_^