Solved

connect to pervasive database via ODBC

Posted on 2003-10-30
2
1,142 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

623 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