Link to home
Start Free TrialLog in
Avatar of Benvor
BenvorFlag for South Africa

asked on

Find Record in Pervasive Database with VB.Net

Hi Experts

I have a Pervasive database to which I can successfully connect and view the records, but now I would just like to Find a record in my database. Can someone please assist me with this please? I use Microsoft Visual Basic 2008

The Var TempInv_No has a integer value of "61809" but I get the Error: "Cannot perform '=' operation on System.String and System.Int32."

The same method with Access works 100% but with Pervasive it doesn't work

Thanx in Advance
Dim dr As DataRow()
        Dim con As New OleDb.OleDbConnection
        Dim ds As New DataSet
 
        Dim da As New OleDb.OleDbDataAdapter
        Dim sql As String
 
 
        cpath = "P:\HH2003"
        con.ConnectionString = "Provider=PervasiveOLEDB;Data Source=" & cpath
 
        con.Open()
        sql = "SELECT * FROM Invoices ORDER BY DocumentNumber"
        da = New OleDb.OleDbDataAdapter(sql, con)
        da.Fill(ds, "Invoices")
        con.Close()
 
            dr = ds.Tables("Invoices").Select("DocumentNumber = " & (TempInv_no))
            If Not (dr Is Nothing) AndAlso dr.Length > 0 Then
 
                MessageBox.Show("Found Invoice: " & dr(0)("DocumentNumber").ToString())
                frmInvoicing.txtInvoice.SelectAll()
                frmInvoicing.txtInvoice.Focus()
                IsinPervasive = True

Open in new window

Avatar of apresto
apresto
Flag of Italy image

Could you post the SQL/Code you are trying to execute, sounds like a casting problem.
Avatar of Benvor

ASKER

SELECT * FROM Invoices ORDER BY DocumentNumber
ASKER CERTIFIED SOLUTION
Avatar of apresto
apresto
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial