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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PEACHTREE - ODBC connection

Status
Not open for further replies.

amigo02

Programmer
Feb 19, 2003
109
I am trying to export data to peachtree from a custom vb application. This could either be with pervasive odbc or BTRIEVE API.

I used odbc connection successfully to read data but I was unable to post data into peachtree. The code is below..

Private Sub Command3_Click()
Dim sConnect As String
Dim Conn As ADODB.Connection
Dim RS As ADODB.Recordset
sConnect = "DSN=PEACH3"
Set Conn = New ADODB.Connection
Conn.Open sConnect, "", ""
Set RS = New ADODB.Recordset
sSQL = "Select * from CUSTOMERS"
RS.Open sSQL, Conn, adOpenStatic, adLockBatchOptimistic, 1
RS.AddNew
RS("Customer_Bill_Name") = "ABC Company"
RS.Update

RS.MoveFirst
List1.AddItem Err.Description

Do While Not RS.EOF
List1.AddItem RS(0)
RS.MoveNext
Loop

End Sub


If you have any code fragments with BTRIEVE API I would appreciate that also..
 
First off, what error do you get when trying to write through ODBC?
Secondly, what version of Pervasive.SQL/Btrieve is Peachtree using?
Here's a Btrieve API call I found:
Code:
lStatus = BTRCALL(BOPEN, PosBlk, lDataBuffer, BufLen, ByVal KeyBuffer, KeyBufLen, KeyNumber)
and the declare statement:
Code:
Declare Function BTRCALL Lib "w3btrv7.dll" (ByVal OpCode As Integer, PositionBlock As Any, DataBuffer As Any, DataLength As Long, KeyBuffer As Any, ByVal KeyLength As Integer, ByVal KeyNumber As Integer) As Integer
The declare above is for Pervasive.SQL V7 and later but might work with Btrieve 6.15 with modification.

info@mirtheil.com
Custom VB and Btrieve development.
Certified Pervasive Developer
Certified Pervasive Technician
 
I use Pervasive v8 and peachtree complete accounting 2004

It does not return any error..

I put the following code to see if there are any errors, but there is none..

If Err.Number > 0 Then
List1.AddItem "Error= " & Err.Description
Else
List1.AddItem "success"
End If


Also when I use Btrieve API to open CUSTOMERS.DAT I get
ERROR # 12;

so I can't open the file at all. The code looks like..


Type RecordBuffer
Number As Double
Dummy As String * 26
End Type

Type VersionBuf
Major As Integer
Minor As Integer
Engine As String * 1
End Type

Type typ_PosBlk
f1(1 To 128) As Byte
End Type

Global DataBuf As RecordBuffer

sub OpenFile()

FileName$ = "C:\PEACHW\company\Customers.dat"
KeyBufLen = 255
KeyBuffer$ = FileName$
BufLen = Len(DataBuf)
KeyNum = 0

Status = BTRCALL(BOPEN, PosBlk(1).f1, DataBuf, BufLen, ByVal KeyBuffer$, KeyBufLen, KeyNum)

If Status <> 0 Then
Msg$ = "Error Opening file! " + Str$(Status)
PrintLB (Msg$)
Else
Msg$ = "File Opened Successfully!"
'PrintLB (Msg$)
End If

end sub
 
If there's no error, then how do you know it didn't work with the ODBC connection?
As far as the status 12, is the file really at: C:\PEACHW\company\Customers.dat
One other thing, try changing:
Code:
Status = BTRCALL(BOPEN, PosBlk(1).f1, DataBuf, BufLen, ByVal KeyBuffer$, KeyBufLen, KeyNum)
to:
Code:
Status = BTRCALL(BOPEN, PosBlk, DataBuf, BufLen, ByVal KeyBuffer$, KeyBufLen, KeyNum)


info@mirtheil.com
Custom VB and Btrieve development.
Certified Pervasive Developer
Certified Pervasive Technician
 
Yes CUSTOMERS.DAT exists in that location..

And changing the code to:

Status = BTRCALL(BOPEN, PosBlk, DataBuf, BufLen, ByVal KeyBuffer$, KeyBufLen, KeyNum)

gives me "type mismatch"


I think may be the DataBuf and BufLen arguments might be causing the problem but I am not sure. What should be these values?

Is there a documentation anywhere about btrieve api and sample code?
 
The documentation is included in the SDK.
What's the declare you are using for the BTRCALL function?

info@mirtheil.com
Custom VB and Btrieve development.
Certified Pervasive Developer
Certified Pervasive Technician
 
as far as the ODBC connection is concerned: I don't get any errors but when I check the data file I don't see a new record..
 
Declare Function BTRCALL Lib "w3btrv7.dll" (ByVal OP, ByVal Pb$, Db As Any, DL As Integer, Kb As Any, ByVal Kl, ByVal Kn) As Integer

in fact I have modified a working sample application provided by pervasive, It actually successfully creates a file and opens it.

what happens is that I modified the 'file open' segment of the code to open a peachtree file which gives me the error 12 during file opening.
 
Try the Declare I had posted previously and then change the PosBlk to what I had suggested. That might help.


info@mirtheil.com
Custom VB and Btrieve development.
Certified Pervasive Developer
Certified Pervasive Technician
 
I did try that but it does not work

Changing code to :
Status = BTRCALL(BOPEN, PosBlk, DataBuf, BufLen, ByVal KeyBuffer$, KeyBufLen, KeyNum)

gives me "Type mismatch" where PosBlk is
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top