.NET 2012连接到Firebird数据库

时间:2015-07-08 10:14:47

标签: vb.net firebird

我无法使用VB.NET 2012连接到Firebird数据库。我通过NuGet包管理器下载了Firebird实体框架提供程序。

我检查了以下参考文献已添加到项目中:

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,但我确实需要一些帮助。

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:-1)

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