我在使用VB连接到火鸟数据库时遇到麻烦。2012年净。我通过NuGet包管理器下载了Firebird实体框架提供程序。
我检查了一下,项目中添加了以下引用:
EntityFramework EntityFramework。火鸟,EntityFramework。SqlServer and firebirdserver . sql . 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,但是我真的需要一些帮助。
答案很简单。因为我使用的是Firebird客户端,所以ServerType应该被设置为Embedded,因为它包含了一个特殊的客户端库,其中包含了服务器本身。
您的连接字符串缺少Firebird运行的主机名