Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

connect to pervasive database via ODBC

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

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…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

927 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