【发布时间】: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移开。通常,此路径需要最高权限才能在此处写入(并且数据库提供程序需要对数据库的写入权限)
-
您需要提供实际的异常堆栈跟踪。