Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

connect to pervasive database via ODBC

Posted on 2003-10-30
2
Medium Priority
?
1,145 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 150 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

Basic Security of Your VPC

So, you’ve got this shiny new VPC and a fancy new application configured on your EC2 servers ready to go. This application is only accessible from your computer, which is great for security, but you need your users to be able to access it! So, what’s the easiest way to do this?

Question has a verified solution.

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

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

718 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