INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

PEACHTREE - ODBC connection

PEACHTREE - ODBC connection

(OP)
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..

RE: PEACHTREE - ODBC connection

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

RE: PEACHTREE - ODBC connection

(OP)
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

RE: PEACHTREE - ODBC connection

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

RE: PEACHTREE - ODBC connection

(OP)
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?

RE: PEACHTREE - ODBC connection

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

RE: PEACHTREE - ODBC connection

(OP)
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..

RE: PEACHTREE - ODBC connection

(OP)
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.

RE: PEACHTREE - ODBC connection

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

RE: PEACHTREE - ODBC connection

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close