Solved

connect to pervasive database via ODBC

Posted on 2003-10-30
2
1,097 Views
Last Modified: 2009-04-02
hello guys,

i want to ask, how i want to connect to pervasive database using vb.net via ODBC. please help me
0
Comment
Question by:beanX
2 Comments
 
LVL 5

Accepted Solution

by:
fantasy1001 earned 50 total points
ID: 9655886
Try this:

Imports System.Data.Odbc

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
     Dim myConnString As String
     Dim mySelectQuery As String
     myConnString = txtConnStr.Text
     Dim myConnection As New OdbcConnection(myConnString)

     mySelectQuery = txtSQL.Text

     Dim myCommand As New OdbcCommand(mySelectQuery, myConnection)
     Dim i As Int32
     Dim sTemp As String
     Dim sTemp2 As String

     ListBox1.Items.Clear()
     Try
          myConnection.Open()
          Dim myReader As OdbcDataReader = myCommand.ExecuteReader()

          While myReader.Read()
               For i = 0 To myReader.FieldCount - 1
                    Select Case myReader.Item(i).GetType().ToString
                         Case "System.TimeSpan"
                              Dim sTimeSpan As TimeSpan
                              sTimeSpan = myReader.Item(i)
                              sTemp2 = sTimeSpan.ToString

                         Case "System.DBNull"
                              sTemp2 = "null"
                         Case Else
                              sTemp2 = CStr(myReader.Item(i))
                   End Select

                   If i = 0 Then
                        sTemp = sTemp2
                   Else
                        sTemp = sTemp & ", " & Trim(sTemp2)
                   End If
              Next
              ListBox1.Items.Add(sTemp)
              sTemp = ""
         End While
         
         ' always call Close when done reading.
         myReader.Close()
         ' always call Close when done with connection.
         myConnection.Close()
       
     Catch ex As Exception
         MsgBox(ex.Message)
     End Try
End Sub

regards,
~ fantasy ~
0
 

Author Comment

by:beanX
ID: 9691219
thanks fantasy
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now