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

Newbie - need to convert this code to sql server in vb6

Newbie - need to convert this code to sql server in vb6

(OP)
Here is my sub...

Public Sub CompileReport()
Dim PrintFlag As Boolean
Dim OnChange$, OpenAmount As Double
Dim DateFlag As Boolean, InvoiceNo$
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Call CreateTemp
Set AccessDb = OpenDatabase(ReportPath$ & "oeslscom.mdb")
Set OESLSCOM = AccessDb.OpenRecordset("OESLSCOM", dbOpenTable)

PrintFlag = False
If txtSalesNo1 = "All" Then
  SalesmanNo1$ = "000"
  SalesmanNo2$ = "zzz"
Else
  SalesmanNo1$ = txtSalesNo1
  SalesmanNo2$ = txtSalesNo2
End If

DocumentDate1$ = ConvertDateTime(txtInvoiceDate1, "DS")
DocumentDate2$ = ConvertDateTime(txtInvoiceDate2, "DS")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
KEY_ARO$ = Space$(255)
AroStatus = BTRCALL(BGETFIRST, AROPNFIL$, REC_ARO, BUF_ARO, ByVal KEY_ARO$, KEY_LEN, 1)
Do Until AroStatus <> 0
  If OnChange$ <> REC_ARO.AR_OPN_CUS_NO & REC_ARO.AR_OPN_APPLY_TO Then
    OpenAmount = 0
    InvoiceNo$ = ""
    DateFlag = False
    OnChange$ = REC_ARO.AR_OPN_CUS_NO & REC_ARO.AR_OPN_APPLY_TO
  End If
    
  OpenAmount = OpenAmount + (Comp3ToVariant(REC_ARO.AR_OPN_AMT1, 8, 2) + Comp3ToVariant(REC_ARO.AR_OPN_AMT2, 8, 2))
  OpenAmount = Format$(OpenAmount, "0.00")
        
  If (REC_ARO.AR_OPN_DOC_TP = "C" Or REC_ARO.AR_OPN_DOC_TP = "P") Then
  If REC_ARO.AR_OPN_DOC_DT >= DocumentDate1$ And REC_ARO.AR_OPN_DOC_DT <= DocumentDate2$ Then
    DateFlag = True
  End If
  End If
    
  txtStatus = KEY_ARO$
  DoEvents
  AroStatus = BTRCALL(BGETNEXT, AROPNFIL$, REC_ARO, BUF_ARO, ByVal KEY_ARO$, KEY_LEN, 1)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  If AroStatus <> 0 Or OnChange$ <> REC_ARO.AR_OPN_CUS_NO & REC_ARO.AR_OPN_APPLY_TO Then
  If DateFlag And OpenAmount = 0 Then
    KEY_ARO$ = OnChange$ & Space$(100)
    AroStatus = BTRCALL(BGETGREATEROREQUAL, AROPNFIL$, REC_ARO, BUF_ARO, ByVal KEY_ARO$, KEY_LEN, 1)
    Do Until AroStatus <> 0 Or Mid$(KEY_ARO$, 1, 20) > OnChange$
      InvoiceNo$ = ""
      If REC_ARO.AR_OPN_DOC_TP = "I" Then InvoiceNo$ = REC_ARO.AR_OPN_DOC_NO
      If REC_ARO.AR_OPN_DOC_TP = "C" Then InvoiceNo$ = REC_ARO.AR_OPN_DOC_NO
      
      Call WriteToTemp(InvoiceNo$, 1)
      AroStatus = BTRCALL(BGETNEXT, AROPNFIL$, REC_ARO, BUF_ARO, ByVal KEY_ARO$, KEY_LEN, 1)
    Loop
  End If
  End If
Loop
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
End Sub

I was wondering if anyone could translate this for me....

AROPNFIL is the table
REC_ARO appears to be the recordset

I am thinking of creating an ADODB recordset...and looping thruough.  I am confused about all the GetNext and BGETGREATEROREQUAL calls in the middle of the loop. How is it sorting the data?  

Thanks for your help.

RE: Newbie - need to convert this code to sql server in vb6

What are you trying to do?  
THe BGETNEXT and BGETGREATEROREQUAL are operation codes in Btrieve.  It's a different method of accessing data.  It's not SQL.

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
http://www.mirtheil.com

RE: Newbie - need to convert this code to sql server in vb6

(OP)
I understand it's not SQL.  My client is moving from Btrieve to SQL Server.  Typically, in sql server, I would create a recordset using ADO and begin looping through the data.  

It appears that I could take..

AroStatus = BTRCALL(BGETFIRST, AROPNFIL$, REC_ARO, BUF_ARO, ByVal KEY_ARO$, KEY_LEN, 1)
statement and do this....


loop through this recordset...
rst.open "select * from aropnfil", conn, ..., ...

the first record i would....

Do Until AroStatus <> 0
  If OnChange$ <> REC_ARO.AR_OPN_CUS_NO & REC_ARO.AR_OPN_APPLY_TO Then
    OpenAmount = 0
    InvoiceNo$ = ""
    DateFlag = False
    OnChange$ = REC_ARO.AR_OPN_CUS_NO & REC_ARO.AR_OPN_APPLY_TO
  End If
    
  OpenAmount = OpenAmount + (Comp3ToVariant(REC_ARO.AR_OPN_AMT1, 8, 2) + Comp3ToVariant(REC_ARO.AR_OPN_AMT2, 8, 2))
  OpenAmount = Format$(OpenAmount, "0.00")
        
  If (REC_ARO.AR_OPN_DOC_TP = "C" Or REC_ARO.AR_OPN_DOC_TP = "P") Then
  If REC_ARO.AR_OPN_DOC_DT >= DocumentDate1$ And REC_ARO.AR_OPN_DOC_DT <= DocumentDate2$ Then
    DateFlag = True
  End If
  End If
    
  txtStatus = KEY_ARO$
  DoEvents


...then, this stuff comes in....

AroStatus = BTRCALL(BGETNEXT, AROPNFIL$, REC_ARO, BUF_ARO, ByVal KEY_ARO$, KEY_LEN, 1)

in sql i would say...

rst.movenext (go to the next record)...is the above saying the same thing?

..the code continues...

 If AroStatus <> 0 Or OnChange$ <> REC_ARO.AR_OPN_CUS_NO & REC_ARO.AR_OPN_APPLY_TO Then
  If DateFlag And OpenAmount = 0 Then
    KEY_ARO$ = OnChange$ & Space$(100)
    AroStatus = BTRCALL(BGETGREATEROREQUAL, AROPNFIL$, REC_ARO, BUF_ARO, ByVal KEY_ARO$, KEY_LEN, 1)


what is BGETGREATEROREQUAL this doing....

getgreater or equal to what?..........

then the loop at the bottom doesn't make sense as we've already done a few get next record statements.  

very confusing...






RE: Newbie - need to convert this code to sql server in vb6

Converting from Btrieve to SQL Server is not a trivial task.  It's not simply a matter of converting one operation to another.  You'd actually be rewriting whole sections.  For example, a BGETFIRST / BGETNEXT loop would be a "recordset".  With SQL, you get a result set when you issue a SELECT. With Btrieve, each operation affects at most one record (with a couple of exceptions).  
The BGETGREATEROREQUAL is a positioning operation.  It takes a value and searches the specified key for that value and finds the first value that is greater than or equal to that value.  In your case, it's looking for the value of KEY_ARO$.  

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
http://www.mirtheil.com

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