none
LINQ C# 3.5 e FireBirdSQL DataProvider , caracter inválido? RRS feed

  • Pergunta

  •  

    Oi Pessoal,

     

    Procurei no fórum, mas não consegui achar, então vai a questão:

     

     

    Estou fazendo uns testes com LINQ, VS2008 e FireBirdSQL DataProvider versão 2.1.0,   fiz um pequeno projeto,  só para listar o conteúdo de uma tabela no BDFireBird  via LINQ.  Porém, na ClasseTeste, no lugar marcado em ClasstTeste.CS é disparado um EXCEPTION, que no final do post eu explico:

     

    App.config

    <connectionStrings>

    <add name="cnFirebird" connectionString="Server=localhost;User=SYSDBA;Password=xuxu;Database=X:\FenixNET\apps\Carin5\bin\Debug\Dat00.gdb" providerName="FirebirdSql.Data.FirebirdClient"/>

    </connectionStrings>

     

    <system.data>

    <DbProviderFactories>

    <add

    name="FirebirdClient Data Provider"

    invariant="FirebirdSql.Data.FirebirdClient"

    description="Provedor de Dados para .NET Framework"

    type="FirebirdSql.Data.FirebirdClient.FirebirdClientFactory, FirebirdSql.Data.FirebirdClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=3750abcc3150b00c" />

    </DbProviderFactories>

    </system.data>

     

     

     

     

    TICKET.CS

    [Table(Name="C5_TICKET")]

    class Ticket

    {

    [Column]

    public int Id { get; set; }

    [Column]

    public string Descatend { get; set; }

    }

     

     

     

    ClasseTeste.CS

    private void FlowExec()

    {

    string connectionString = ConfigurationManager.ConnectionStrings["cnFirebird"].ConnectionString;

    FbConnection FireBirdConexx = new FbConnection( connectionString);

    DataContext dataContext = new DataContext( FireBirdConexx );

    dataContext.Log = Console.Out;

     

    var tickets = from b in dataContext.GetTable<Ticket>() 

                       select b;

     

    foreach (Ticket b in tickets)     //  <--------- LUGAR ONDE O EXCEPTION É LANÇADO

    {

    Console.Write( b.Descatend );

    }

    //dataContext.SubmitChanges();

    }

     

     

     

     

     

    EXCEPTION PARA O CONSOLE VISUAL STUDIO

    SELECT [t0].[Id], [t0].[Descatend]

    FROM [C5_TICKET] AS [t0]

    -- Context: SqlProvider(Sql2005) Model: AttributedMetaModel Build: 3.5.21022.8

    A first chance exception of type 'FirebirdSql.Data.FirebirdClient.FbException' occurred 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>Unhandled exception</Description><AppDomain>WindowsFormsApplication1.vshost.exe</AppDomain><Exception><ExceptionType>FirebirdSql.Data.FirebirdClient.FbException, FirebirdSql.Data.FirebirdClient, Version=2.1.0.0, Culture=neutral, PublicKeyToken=3750abcc3150b00c</ExceptionType><Message>Dynamic SQL Error

    SQL error code = -104

    Token unknown - line 1, char 8

    [</Message><StackTrace> at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteReader(CommandBehavior behavior)

    at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteDbDataReader(CommandBehavior behavior)

    at System.Data.Common.DbCommand.ExecuteReader()

    at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult)

    at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries)

    at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)

    at System.Data.Linq.DataQuery`1.System.Collections.Generic.IEnumerable&amp;lt;T&amp;gt;.GetEnumerator()

    at WindowsFormsApplication1.Form1.FlowExec() in X:\CARIN5FLOW\Carin5Flow\WindowsFormsApplication1\Form1.cs:line 42

    at WindowsFormsApplication1.Form1.button1_Click(Object sender, EventArgs e) in X:\CARIN5FLOW\Carin5Flow\WindowsFormsApplication1\Form1.cs:line 26

    at System.Windows.Forms.Control.OnClick(EventArgs e)

    at System.Windows.Forms.Button.OnClick(EventArgs e)

    at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)

    at System.Windows.Forms.Control.WmMouseUp(Message&amp;amp; m, MouseButtons button, Int32 clicks)

    at System.Windows.Forms.Control.WndProc(Message&amp;amp; m)

    at System.Windows.Forms.ButtonBase.WndProc(Message&amp;amp; m)

    at System.Windows.Forms.Button.WndProc(Message&amp;amp; m)

    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp;amp; m)

    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp;amp; m)

    at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&amp;amp; msg)

    at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)

    at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)

    at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)

    at System.Windows.Forms.Application.Run(Form mainForm)

    at WindowsFormsApplication1.Program.Main() in X:\CARIN5FLOW\Carin5Flow\WindowsFormsApplication1\Program.cs:line 18

    at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)

    at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)

    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)

    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

    at System.Threading.ThreadHelper.ThreadStart()</StackTrace><ExceptionString>FirebirdSql.Data.FirebirdClient.FbException: Dynamic SQL Error

    SQL error code = -104

    Token unknown - line 1, char 8

    [ ---&amp;gt; FirebirdSql.Data.Common.IscException: Exception of type 'FirebirdSql.Data.Common.IscException' was thrown.

    at FirebirdSql.Data.Client.Gds.GdsConnection.ReadStatusVector()

    at FirebirdSql.Data.Client.Gds.GdsConnection.ReadResponse()

    at FirebirdSql.Data.Client.Gds.GdsDatabase.ReadResponse()

    at FirebirdSql.Data.Client.Gds.GdsStatement.Prepare(String commandText)

    at FirebirdSql.Data.FirebirdClient.FbCommand.Prepare(Boolean returnsSet)

    at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteCommand(CommandBehavior behavior, Boolean returnsSet)

    at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteReader(CommandBehavior behavior)

    --- End of inner exception stack trace ---

    at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteReader(CommandBehavior behavior)

    at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteDbDataReader(CommandBehavior behavior)

    at System.Data.Common.DbCommand.ExecuteReader()

    at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult)

    at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries)

    at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)

    at System.Data.Linq.DataQuery`1.System.Collections.Generic.IEnumerable&amp;lt;T&amp;gt;.GetEnumerator()

    at WindowsFormsApplication1.Form1.FlowExec() in X:\CARIN5FLOW\Carin5Flow\WindowsFormsApplication1\Form1.cs:line 42

    at WindowsFormsApplication1.Form1.button1_Click(Object sender, EventArgs e) in X:\CARIN5FLOW\Carin5Flow\WindowsFormsApplication1\Form1.cs:line 26

    at System.Windows.Forms.Control.OnClick(EventArgs e)

    at System.Windows.Forms.Button.OnClick(EventArgs e)

    at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)

    at System.Windows.Forms.Control.WmMouseUp(Message&amp;amp; m, MouseButtons button, Int32 clicks)

    at System.Windows.Forms.Control.WndProc(Message&amp;amp; m)

    at System.Windows.Forms.ButtonBase.WndProc(Message&amp;amp; m)

    at System.Windows.Forms.Button.WndProc(Message&amp;amp; m)

    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp;amp; m)

    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp;amp; m)

    at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&amp;amp; msg)

    at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)

    at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)

    at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)

    at System.Windows.Forms.Application.Run(Form mainForm)

    at WindowsFormsApplication1.Program.Main() in X:\CARIN5FLOW\Carin5Flow\WindowsFormsApplication1\Program.cs:line 18

    at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)

    at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)

    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)

    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

    at System.Threading.ThreadHelper.ThreadStart()</ExceptionString><InnerException><ExceptionType>FirebirdSql.Data.Common.IscException, FirebirdSql.Data.FirebirdClient, Version=2.1.0.0, Culture=neutral, PublicKeyToken=3750abcc3150b00c</ExceptionType><Message>Exception of type 'FirebirdSql.Data.Common.IscException' was thrown.</Message><StackTrace> at FirebirdSql.Data.Client.Gds.GdsConnection.ReadStatusVector()

    at FirebirdSql.Data.Client.Gds.GdsConnection.ReadResponse()

    at FirebirdSql.Data.Client.Gds.GdsDatabase.ReadResponse()

    at FirebirdSql.Data.Client.Gds.GdsStatement.Prepare(String commandText)

    at FirebirdSql.Data.FirebirdClient.FbCommand.Prepare(Boolean returnsSet)

    at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteCommand(CommandBehavior behavior, Boolean returnsSet)

    at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteReader(CommandBehavior behavior)</StackTrace><ExceptionString>FirebirdSql.Data.Common.IscException: Exception of type 'FirebirdSql.Data.Common.IscException' was thrown.

    at FirebirdSql.Data.Client.Gds.GdsConnection.ReadStatusVector()

    at FirebirdSql.Data.Client.Gds.GdsConnection.ReadResponse()

    at FirebirdSql.Data.Client.Gds.GdsDatabase.ReadResponse()

    at FirebirdSql.Data.Client.Gds.GdsStatement.Prepare(String commandText)

    at FirebirdSql.Data.FirebirdClient.FbCommand.Prepare(Boolean returnsSet)

    at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteCommand(CommandBehavior behavior, Boolean returnsSet)

    at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteReader(CommandBehavior behavior)</ExceptionString></InnerException></Exception></TraceRecord>

     

     

     

    Agora vai a questão final,  o  problema que gera esta exception é justamente os colchetes "["  no comando SQL enviado pelo provider para o FireBird???     Eliminando os colchetes, acho  que evitaria de ser disparado o erro "Token unknown - line 1, char 8" ?

     

    Com este erro, estou impedido de copiar os dados do BD para o BO.

     

     

     

    Abraço

    Leandro

    domingo, 24 de fevereiro de 2008 01:44

Respostas

  • Grande,

     

    Aparentemente não existe suporte para LINQ com Firebird.

    Escutei falar que estão fazendo um LINQ to Firebird, mas não sei em que pé que esta.

     

    quarta-feira, 27 de fevereiro de 2008 17:03
    Moderador

Todas as Respostas

  • Grande,

     

    Aparentemente não existe suporte para LINQ com Firebird.

    Escutei falar que estão fazendo um LINQ to Firebird, mas não sei em que pé que esta.

     

    quarta-feira, 27 de fevereiro de 2008 17:03
    Moderador
  •  ViewState wrote:

    Grande,

     

    Aparentemente não existe suporte para LINQ com Firebird.

    Escutei falar que estão fazendo um LINQ to Firebird, mas não sei em que pé que esta.

     



    Pois é, eu já estava imaginando isso, até porque no site de suporte deles, nada se fala do LINQ ser compatível mesmo.

    Acho que o remédio é esperar mesmo..

    No mais  , Valeu bastante ViewState!!


    Abraço
    quarta-feira, 27 de fevereiro de 2008 17:13
  • Cara, como vc fez pra gerar o datacontext (dbml) do firebird?

    Eu consegui fazer funcionar o .NET Framework Data Provider for Firebird

    Mas quando arrasto as tabelas para o dbml da a mensagem de que provider não possui suporte...

    segunda-feira, 19 de abril de 2010 01:36