Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vb6 and pervasive version 9 or 8

Status
Not open for further replies.
Nov 21, 2010
4
TZ
i want script of vb6 to connect pervasive version 9 (9.6) or older

in database there is no username and password

kindly provide the code

 
Using VB6, you have several options for connecting to the PSQL engine. You can use the Btrieve API, Pervasive ActiveX control, ODBC (through DAO, RDO, ADO, or ODBC API), or OLEDB (through ADO).

You have to decide which method is best for you. Once you've decided, you should look at the Pervasive web site ( They have a number of samples using those interfaces.

If you are still having problems, post the specific problems you are having.


Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
 
Mr. Mirtheil,

Kind to you for reply on my query

I had forget to mention i want to use odbc and i had visited said web site but not finding any option to look for document/s.

i had downloaded document from this web site related

psql_v95_docs which contains 12 files as

01) Advanced_Operations_Guide
02) DDF_Builder_Users_Guide
03) Getting_Started_Server
04) Getting_Started_Workgroup
05) Products_and_Services
06) PSQL_ActiveX_Guide
07) PSQL_Addendum
08) PSQL_ADONET_Guide
09) PSQL_BtrieveAPI_Guide
10) PSQL_DTI_Guide
11) PSQL_DTO_Guide
&
12) Whats_New

respectively

but i am not ure which document to refer

if i get simple vb6 program with codeing to connect to sql and generate the crystal report 8.5 then it will be good for me as i am biginer learner of vb6 and crystal report.

waiting for the quick anticipation.
 
Connecting to Pervasive through ODBC in VB is the same as connecting to any database. Here's a very simple sample:
Code:
    conn.ConnectionString = "DSN=DEMODATA"
    conn.Open
    Dim sTemp As String
    sTemp = "select * from class"
    
    Dim rs As New ADODB.Recordset
    Set rs = New ADODB.Recordset
    
    rs.CursorType = adOpenKeyset
    
    Set rs = conn.Execute(sTemp)
    
    rs.MoveFirst
    msgbox ("MoveFirst returns" & rs(0).Value)
    
    conn.Close

I don't have any code for Crystal Reports though.

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
 
Mr. Mirtheil

i heartly appreciate your work (also to community who are beginner)

following is my code in vb6 as i said i am new in this

where i am connecting to pervasive verion 8 or higher

Dim CreateDept As Boolean
Dim GLServerName As String
Dim GLUserName As String
Dim GLPassword As String
Dim GLDatabase As String
Dim GLConnection As New ADODB.Connection
Private Sub CmdClo_Click()
Unload Me
End Sub
Private Sub cmdLogin_Click()
On Error GoTo Errhandler
If txtDatabaseName.Text = "" Or txtServer.Text = "" Then
MsgBox "Prduct Name <OR> Server Name <OR> Database Name cannot be empty"
Else
Dim str As String
str = "Provider=PervasiveOLEDB;Data Source=" & Trim(txtServer.Text) & ";UID=" & Trim(txtLogin.Text) & ";PWD=" & Trim(txtPwd.Text) & ";Initial Catalog=" & Trim(txtDatabaseName.Text) & ""
Dim ans As Boolean
GLServerName = Trim(txtServer.Text)
GLUserName = Trim(txtLogin.Text)
GLPassword = Trim(txtPwd.Text)
GLDatabase = Trim(txtDatabaseName.Text)
Set GLConnection = New ADODB.Connection
strconnect = str
GLConnection.ConnectionString = str
GLConnection.Open str
ans = True
Dim rs As New ADODB.Recordset
strsql = "select DocumentNumber From HistoryHeader where DocumentNumber<>'' and DocumentType=3 order by DocumentNumber"
rs.Open strsql, GLConnection, adOpenKeyset
If rs.RecordCount > 0 Then
Dim i As Integer
For i = 0 To rs.RecordCount - 1
cmbInvoice.AddItem rs!InvNumber, i
rs.MoveNext
Next i
End If
End If
Frame1.Visible = True
Set rs = Nothing
cmdLogin.Enabled = False
Exit Sub
Errhandler:
Dim enumber As Long ' Integer
enumber = Err.Number
MsgBox Err.Description, vbCritical + vbOKOnly, gstrMessage
Err.Clear
End Sub
Private Sub cmdPrint_Click()
Dim invnum As String
invnum = ""
If cmbInvoice.List(cmbInvoice.ListIndex) = "" Then
Exit Sub
Else
invnum = cmbInvoice.List(cmbInvoice.ListIndex)
End If
Set cmd = New ADODB.Command
cmd.ActiveConnection = GLConnection
cmd.CommandType = adCmdStoredProc
' cmd.CommandText = "[dbo].[InvDetailz]"
cmd.Parameters.Append cmd.CreateParameter("@InvNum", adVarChar, adParamInput, 20, invnum)
Set rs = cmd.Execute
Set cmd.ActiveConnection = Nothing
Dim str As String
str = "dsn=TEST02;uid=" & txtLogin.Text & ";pwd=" & txtPwd.Text & ";dsq=" & GLDatabase & ";"
Dim ans As Boolean
Set GLConnection = New ADODB.Connection
strconnect = str
GLConnection.ConnectionString = str
GLConnection.CursorLocation = adUseClient
GLConnection.Open str
Dim Repstr As String
Repstr = "" & GLServerName & ";" & GLUserName & ";" & GLPassword & ";DSQ=" & GLDatabase & ";"
CrystalReport1.Connect = str ' Repstr
CrystalReport1.ReportFileName = App.Path & "\PP_Invoice.rpt"
CrystalReport1.WindowShowPrintBtn = True
CrystalReport1.WindowShowPrintSetupBtn = True
CrystalReport1.WindowState = crptMaximized
CrystalReport1.Action = 1
CrystalReport1.Destination = crptToWindow
CrystalReport1.Reset
End Sub
Private Sub cmdShow_Click()
cmbInvoice.Clear
Dim rs As New ADODB.Recordset
strsql = "select DocumentNumber From HistoryHeader where DocumentNumber<>'' and DocumentType=3 and DocumentDate between '" & Format(DTPicker1.Value, "mm/dd/yyyy") & "' and '" & Format(DTPicker2.Value, "mm/dd/yyyy") & "' order by DocumentNumber"
rs.Open strsql, GLConnection, adOpenKeyset
If rs.RecordCount > 0 Then
Dim i As Integer
For i = 0 To rs.RecordCount - 1
cmbInvoice.AddItem rs!InvNumber, i
rs.MoveNext
Next i
End If

End Sub
Private Sub Command2_Click()
Unload Me
Beep
End Sub
Private Sub Form_Load()
Frame1.Visible = False
DTPicker2.Value = Format(DateTime.Now, "dd-MM-yyyy")
End Sub

requirement
-----------

1) how to connect to pervasive as per this code it is showing unspecified error where server name is defined as JAYESH-492A222F, User Name and Password is BLANK and Database is TEST02.

i had created DSN under ODBC as TEST02


2) how to write procedure where row has to match with different tables

select historyheader.currencycode, historylines.documentnumber, customermaster.customerdesc, currencyfile.fieldformat from historylines join historyheader on historylines.documentnumber = historyheader.documentnumber left join customermaster on historyheader.customercode = customermaster.customercode left join currencyfile on historyheader.currencycode = currencyfile.currcode where historyheader.documentnumber = @InvNum

kindly guide me to proceed further

waiting for your favourable reply
 
First, you have two types of connections in your code. One has "Provider=PervasiveOLEDB" and the other has "DSN=". You need to use on type. You shouldn't mix methods. I would suggest using "DSN=" rather than "provider=PervasiveOLEDB".

Second, Why do you want a stored procedure? You've got a query. Just use it. You don't gain any performance by using a stored procedure. Just remember that parameters in Pervasive use "?" rather than the "@<paramname>" notation.

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
 
as said i am new in this

can you change the code as i had tried to remove one but getting the error, so it is better u do from yr end

 
I'm not here to write your code for you. You need to decide which method to use and then apply it. One more thing I did notice is that you have "DSQ=" in one of your connection strings. If you are specifying a Pervasive Database name, it should be "DBQ=".

If you want someone to fix your code, you can look into consulting services. There are several participants in multiple forums that can do what you are looking for. You cannot solicit consulting services here though. You would have to contact the people directly.

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top