【问题标题】:.NET 2012 Connect to Firebird Database.NET 2012 连接到 Firebird 数据库
【发布时间】:2015-07-10 00:25:57
【问题描述】:

我在使用 VB.NET 2012 连接到 Firebird 数据库时遇到问题。我通过 NuGet 包管理器下载了 Firebird Entity Framework Provider。

我检查并在项目中添加了以下参考:

EntityFramework、EntityFramework.Firebird、EntityFramework.SqlServer 和 FirebirdSql.Data.FirebirdClient。

当我运行程序时,输出窗口显示以下内容:

A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
A first chance exception of type 'FirebirdSql.Data.Common.IscException' occurred in FirebirdSql.Data.FirebirdClient.dll
A first chance exception of type 'FirebirdSql.Data.FirebirdClient.FbException' occurred in FirebirdSql.Data.FirebirdClient.dll
A first chance exception of type 'FirebirdSql.Data.FirebirdClient.FbException' occurred in FirebirdSql.Data.FirebirdClient.dll

应用程序中没有显示任何错误,但没有任何反应

这是我的代码:

Imports FirebirdSql.Data.FirebirdClient
Imports System.Text
Imports System.Net

Public Class Form1

    Dim con As FbConnection
    Dim cs As FbConnectionStringBuilder

    Public Sub New()

        InitializeComponent()

        cs = New FbConnectionStringBuilder
        cs.Database = "C:\database.fdb"
        cs.ServerType = FbServerType.Default
        cs.UserID = "SYSDBA"
        cs.Password = "password"

    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load

        con = New FbConnection(cs.ToString)
        con.Open()

        Dim sCmd As FbCommand
        Dim sql As String
        Dim ds As FbDataReader

        sql = "SELECT something FROM TABLE"

        sCmd = New FbCommand()
        sCmd.Connection = con
        sCmd.CommandText = sql
        ds = sCmd.ExecuteReader

        Dim str As New StringBuilder

        While (ds.Read)

            MsgBox(ds.GetString(0))

        End While

        ds.Close()

        End

    End Sub

End Class

我已经尝试过运行各种版本的 Firebird,但我真的需要一些帮助。

【问题讨论】:

  • 不确定,但我建议将该数据库从系统盘的ROOT移开。通常,此路径需要最高权限才能在此处写入(并且数据库提供程序需要对数据库的写入权限)
  • 您需要提供实际的异常堆栈跟踪。

标签: vb.net firebird


【解决方案1】:

答案很简单。因为我使用的是 Firebird 客户端,所以应该将 ServerType 设置为 Embedded,因为它包含一个包含服务器本身的特殊客户端库。

【讨论】:

    【解决方案2】:

    您的连接字符串缺少运行 Firebird 的主机名。

    【讨论】:

    • 不,这是不正确的,因为我有相同的代码在另一个 Windows 机器上工作。
    • 看看你自己的答案,你应该告诉我们你正在使用Embedded,那么显然你不需要主机名。
    • 我确实声明我使用的是 Firebird Entity Framework Provider,它只能使用 Embedded。
    猜你喜欢
    • 1970-01-01
    • 2020-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-25
    • 1970-01-01
    相关资源
    最近更新 更多