我是VB.NET的新手。
我正在尝试连接INTERBASE数据库(本地)并收到错误:
我尝试过很多东西而没有任何帮助。 无法弄清楚我做错了什么或错过了
Imports FirebirdSql
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim query As String = "select * from EMPLOYEE"
Dim csb As FbConnectionStringBuilder
Dim cnn As New FbConnection
csb = New FbConnectionStringBuilder()
csb.DataSource = "LOCALHOST"
csb.ServerType = 0
csb.Database = "c:\db\office.gdb"
csb.UserID = "SYSDBA"
csb.Password = "masterkey"
cnn = New FbConnection(csb.ToString)
Dim da As New FirebirdSql.Data.FirebirdClient.FbDataAdapter(query, cnn)
Dim ds As New DataSet
Dim dt As New DataTable
Try
cnn.Open()
da.Fill(dt)
cnn.Close()
cnn.Dispose()
Dim ans As String
If dt.Rows.Count > 0 Then
For Each row As DataRow In dt.Rows
ans = Convert.ToString(row.Item(1))
TextBox1.Text = ans
Next
Else
TextBox1.Text = "Record Not Found"
End If
Catch ex As Exception
MessageBox.Show("Error: " & ex.Message, "Error")
End Try
End Sub
End Class
答案 0 :(得分:2)
您无法使用FirebirdClient
连接到InterBase。 Firebird和InterBase不一样。
答案 1 :(得分:0)
所以...! 挖网之后我终于开始工作了!
已安装“Firebird_ODBC_2.0.3.154_Win32.exe”已从http://www.firebirdsql.org/en/odbc-driver/下载
修复了我的脚本:
Dim query As String = "select * from EMPLOYEE"
Dim cnn As New Odbc.OdbcConnection()
Dim estring As New Odbc.OdbcConnectionStringBuilder("DRIVER=Firebird/InterBase(r) driver;UID=SYSDBA;PWD=masterkey;DBNAME=128.1.7.81:C:\office\db\office.gdb;")
cnn = New OdbcConnection(estring.ToString)
Dim da As New OdbcDataAdapter("select * from EMPLOYEE", estring.ToString)
Dim ds As New DataSet
Dim dt As New DataTable
Try
cnn.Open()
da.Fill(dt)
cnn.Close()
cnn.Dispose()
' (and so one).....
建立连接,我很高兴! 您对Firdbird的.NET OLE DB提供程序(不使用Interbase)是正确的,谢谢大家的帮助。
我希望这个帖子可以帮助其他人解决这个问题。