Solved

connect to pervasive database via ODBC

Posted on 2003-10-30
2
1,136 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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.   …
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

710 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