VB.NET - Firebird ODBC adapter fill datagrid.
-
I am developing a Windows Forms application with firebird DB using ODBC driver to connect to the database and should fill a DataGrid with the results of a query; This is the code but I do not work in ..... what am I wrong? Private Sub Form1_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown Dim cn As OdbcConnection cn = New OdbcConnection("dsn=PHOENIXDB;uid=SYSDBA;pwd=masterkey;") Dim mystring As String = "Select * from SSN_REGIONE" Dim cmd As OdbcCommand = New OdbcCommand(mystring) Dim daSSNregione As New OdbcDataAdapter Dim dsSSNregione As New DataSet cn.Open() Try daSSNregione.SelectCommand = cmd daSSNregione.Fill(dsSSNregione) DataGridViewX1.DataSource = dsSSNregione Catch ex As Exception MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OkOnly, "Connection Error !!") End Try cn.Close() End Sub
-
I am developing a Windows Forms application with firebird DB using ODBC driver to connect to the database and should fill a DataGrid with the results of a query; This is the code but I do not work in ..... what am I wrong? Private Sub Form1_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown Dim cn As OdbcConnection cn = New OdbcConnection("dsn=PHOENIXDB;uid=SYSDBA;pwd=masterkey;") Dim mystring As String = "Select * from SSN_REGIONE" Dim cmd As OdbcCommand = New OdbcCommand(mystring) Dim daSSNregione As New OdbcDataAdapter Dim dsSSNregione As New DataSet cn.Open() Try daSSNregione.SelectCommand = cmd daSSNregione.Fill(dsSSNregione) DataGridViewX1.DataSource = dsSSNregione Catch ex As Exception MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OkOnly, "Connection Error !!") End Try cn.Close() End Sub
Wrong section - post it under VisualBasic section. Please wrap your code in a preformatted block fo the ease of reading. Please do not crosspost between Forums and Quick Answers. What does it menas "it doesn't work"? Does not compile? Does not fill? Returns an error? Try using the debugger to see if the connection is open for example.
Geek code v 3.12 { GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- r++>+++ y+++* Weapons extension: ma- k++ F+2 X }