Reputation: 161
i'm pretty new in VB.NET.
i'm trying to connect INTERBASE database (local) and get an error:
I've tried many things and nothing helped. can't figure out what am I doing wrong or missed
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
Upvotes: 0
Views: 952
Reputation: 161
So...!!! After digging the net I finally got it working!
Installed "Firebird_ODBC_2.0.3.154_Win32.exe" Downloaded from http://www.firebirdsql.org/en/odbc-driver/
fixed my script:
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).....
The connection established and I'm happy! You were right about .NET OLE DB Provider for Firdbird (not working with Interbase), thank you all for the help.
I hope that this thread will help others with this problem.
Upvotes: 1
Reputation: 4150
You cannot use FirebirdClient
to connect to InterBase. Firebird and InterBase are not the same.
Upvotes: 2