Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 359
  • Last Modified:

Calling Function From a COM DLL

Hi,

I did it so many Times, but for Some Reason when  I call a Function from COM object it throws the Following Error in a ASP page..

 An exception occurred: 'AddORderHeader'


Here is my Class in Visual Basic...

Public Function AddORderHeader(ByVal OrderArray, ByVal Lines) As String

    Dim CV, db, Rs, sql, sql2, mainSql, _
    ORDR_NUMBER, ORDR_STATUS, ORDR_SHIP_TO, ORDR_DATE, ORDR_SHIPVIA, _
    ORDR_SLSPER, ORDR_SHPCHRGS, ORDR_TAX1_AMOUNT, ORDR_COMMENT, _
    ORDR_TAX1_RATE, ORDR_NETTOTAL, ORDR_CUST, _
    ORDR_Entered, ORDR_BILLTO_ADDRESS1, ORDR_BILLTO_ADDRESS2, ORDR_BILLTO_CITY, _
    ORDR_BILLTO_STATE_PROV, ORDR_BILLTO_POSTAL_ZIP, ORDR_BILLTO_COUNTRY, _
    ORDR_BILLTO_COMPANY, ORDR_BILLTO_PHONE, ORDR_BILLTO_PHONE2, _
    ORDR_BILLTO_FAX, ORDR_BILLTO_EMAIL, ORDR_BILLTO_FIRST_NAME, _
    ORDR_BILLTO_LAST_NAME, ORDR_SHIPTO_ADDRESS1, ORDR_SHIPTO_ADDRESS2, _
    ORDR_SHIPTO_CITY, ORDR_SHIPTO_STATE_PROV, ORDR_SHIPTO_POSTAL_ZIP, _
    ORDR_SHIPTO_COUNTRY, ORDR_SHIPTO_COMPANY, ORDR_SHIPTO_PHONE, _
    ORDR_SHIPTO_PHONE2, ORDR_SHIPTO_FAX, ORDR_SHIPTO_EMAIL, _
    ORDR_SHIPTO_FIRST_NAME, ORDR_SHIPTO_LAST_NAME, ORDR_CustomText1, ORDR_CustomText2, _
    ORDR_CustomText4, ORDR_CreditCardNumber, _
    ORDR_CardExpiryMth, ORDR_CardExpiryYear, ORDR_NameOnCard, _
    ORDR_CardType, ORDR_CardSettleError, _
    ORDR_CardCVV, ORDR_ShipDate, ORDR_ShipTrackNo, ORDR_Refer
   
   
    CV = OrderArray
   
    ORDR_NUMBER = NxtOrdId("everydayfurnishings", "A") 'CV(0)
    ORDR_STATUS = CV(1)
    ORDR_SHIP_TO = CV(2)
    ORDR_DATE = CV(3)
    ORDR_SHIPVIA = CV(4)
    ORDR_SLSPER = CV(5)
    ORDR_SHPCHRGS = CV(6)
    ORDR_TAX1_AMOUNT = CV(7)
    ORDR_TAX1_RATE = CV(8)
    ORDR_NETTOTAL = CV(9)
    ORDR_CUST = CV(10)
    ORDR_Entered = CV(11)
    ORDR_BILLTO_ADDRESS1 = CV(12)
    ORDR_BILLTO_ADDRESS2 = CV(13)
    ORDR_BILLTO_CITY = CV(14)
    ORDR_BILLTO_STATE_PROV = CV(15)
    ORDR_BILLTO_POSTAL_ZIP = CV(16)
    ORDR_BILLTO_COUNTRY = CV(17)
    ORDR_BILLTO_COMPANY = CV(18)
    ORDR_BILLTO_PHONE = CV(19)
    ORDR_BILLTO_PHONE2 = CV(20)
    ORDR_BILLTO_FAX = CV(21)
    ORDR_BILLTO_EMAIL = CV(22)
    ORDR_BILLTO_FIRST_NAME = CV(23)
    ORDR_BILLTO_LAST_NAME = CV(24)
    ORDR_SHIPTO_ADDRESS1 = CV(25)
    ORDR_SHIPTO_ADDRESS2 = CV(26)
    ORDR_SHIPTO_CITY = CV(27)
    ORDR_SHIPTO_STATE_PROV = CV(28)
    ORDR_SHIPTO_POSTAL_ZIP = CV(29)
    ORDR_SHIPTO_COUNTRY = CV(30)
    ORDR_SHIPTO_COMPANY = CV(31)
    ORDR_SHIPTO_PHONE = CV(32)
    ORDR_SHIPTO_PHONE2 = CV(33)
    ORDR_SHIPTO_FAX = CV(34)
    ORDR_SHIPTO_EMAIL = CV(35)
    ORDR_SHIPTO_FIRST_NAME = CV(36)
    ORDR_SHIPTO_LAST_NAME = CV(37)
    ORDR_CustomText1 = CV(38)
    ORDR_CustomText2 = CV(39)
    ORDR_CustomText4 = CV(40)
    ORDR_CreditCardNumber = CV(41)
    ORDR_CardExpiryMth = CV(42)
    ORDR_CardExpiryYear = CV(43)
    ORDR_NameOnCard = CV(44)
    ORDR_CardType = CV(45)
    ORDR_CardSettleError = CV(46)
    ORDR_CardCVV = CV(47)
    ORDR_ShipDate = CV(48)
    ORDR_ShipTrackNo = CV(49)
    ORDR_Refer = CV(50)


   Set db = getConn()
   Set Rs = CreateObject("ADODB.RECORDSET")
   Rs.open "Select 1 From FOrder_header where ORDR_NUMBER = '" & ORDR_NUMBER & "'", db
   
   If Rs.EOF Then
   
    sql = "INSERT INTO FORDER_HEADER" & _
    "(ORDR_NUMBER, ORDR_STATUS, ORDR_SHIP_TO, ORDR_DATE, ORDR_SHIPVIA," & _
    "ORDR_SLSPER , ORDR_SHPCHRGS, ORDR_TAX1_AMOUNT, ORDR_COMMENT, " & _
    "ORDR_TAX1_RATE , ORDR_NETTOTAL, ORDR_CUST," & _
    "ORDR_Entered , ORDR_BILLTO_ADDRESS1, ORDR_BILLTO_ADDRESS2, ORDR_BILLTO_CITY," & _
    "ORDR_BILLTO_STATE_PROV , ORDR_BILLTO_POSTAL_ZIP, ORDR_BILLTO_COUNTRY," & _
    "ORDR_BILLTO_COMPANY , ORDR_BILLTO_PHONE, ORDR_BILLTO_PHONE2," & _
    "ORDR_BILLTO_FAX , ORDR_BILLTO_EMAIL, ORDR_BILLTO_FIRST_NAME," & _
    "ORDR_BILLTO_LAST_NAME , ORDR_SHIPTO_ADDRESS1, ORDR_SHIPTO_ADDRESS2," & _
    "ORDR_SHIPTO_CITY , ORDR_SHIPTO_STATE_PROV, ORDR_SHIPTO_POSTAL_ZIP," & _
    "ORDR_SHIPTO_COUNTRY , ORDR_SHIPTO_COMPANY, ORDR_SHIPTO_PHONE," & _
    "ORDR_SHIPTO_PHONE2 , ORDR_SHIPTO_FAX, ORDR_SHIPTO_EMAIL," & _
    "ORDR_SHIPTO_FIRST_NAME , ORDR_SHIPTO_LAST_NAME, ORDR_CustomText1, ORDR_CustomText2," & _
    "ORDR_CustomText4 , ORDR_CreditCardNumber," & _
    "ORDR_CardExpiryMth , ORDR_CardExpiryYear, ORDR_NameOnCard," & _
    "ORDR_CardType , ORDR_CardSettleError," & _
    "ORDR_CardCVV , ORDR_ShipDate, ORDR_ShipTrackNo, ORDR_Refer, XT_SENT_TO_REMOTE)"


    sql2 = " Values(" & _
    "'" & ORDR_NUMBER & "', '" & ORDR_STATUS & "', '" & ORDR_SHIP_TO & "', '" & ORDR_DATE & "', '" & ORDR_SHIPVIA & "'," & _
    "'" & ORDR_SLSPER & "' , '" & ORDR_SHPCHRGS & "', '" & ORDR_TAX1_AMOUNT & "', '" & ORDR_COMMENT & "', " & _
    "'" & ORDR_TAX1_RATE & "' , '" & ORDR_NETTOTAL & "', '" & ORDR_CUST & "'," & _
    "'" & ORDR_Entered & "' , '" & ORDR_BILLTO_ADDRESS1 & "', '" & ORDR_BILLTO_ADDRESS2 & "', '" & ORDR_BILLTO_CITY & "'," & _
    "'" & ORDR_BILLTO_STATE_PROV & "' , '" & ORDR_BILLTO_POSTAL_ZIP & "', '" & ORDR_BILLTO_COUNTRY & "'," & _
    "'" & ORDR_BILLTO_COMPANY & "' , '" & ORDR_BILLTO_PHONE & "', '" & ORDR_BILLTO_PHONE2 & "'," & _
    "'" & ORDR_BILLTO_FAX & "' , '" & ORDR_BILLTO_EMAIL & "', '" & ORDR_BILLTO_FIRST_NAME & "'," & _
    "'" & ORDR_BILLTO_LAST_NAME & "' , '" & ORDR_SHIPTO_ADDRESS1 & "', '" & ORDR_SHIPTO_ADDRESS2 & "'," & _
    "'" & ORDR_SHIPTO_CITY & "' , '" & ORDR_SHIPTO_STATE_PROV & "', '" & ORDR_SHIPTO_POSTAL_ZIP & "'," & _
    "'" & ORDR_SHIPTO_COUNTRY & "' , '" & ORDR_SHIPTO_COMPANY & "', '" & ORDR_SHIPTO_PHONE & "'," & _
    "'" & ORDR_SHIPTO_PHONE2 & "' , '" & ORDR_SHIPTO_FAX & "', '" & ORDR_SHIPTO_EMAIL & "'," & _
    "'" & ORDR_SHIPTO_FIRST_NAME & "' , '" & ORDR_SHIPTO_LAST_NAME & "', '" & ORDR_CustomText1 & "', '" & ORDR_CustomText2 & "'," & _
    "'" & ORDR_CustomText4 & "' , '" & ORDR_CreditCardNumber & "'," & _
    "'" & ORDR_CardExpiryMth & "' , '" & ORDR_CardExpiryYear & "', '" & ORDR_NameOnCard & "'," & _
    "'" & ORDR_CardType & "' , '" & ORDR_CardSettleError & "'," & _
    "'" & ORDR_CardCVV & "' , '" & ORDR_ShipDate & "', '" & ORDR_ShipTrackNo & "', '" & ORDR_Refer & "', 1" & _
    ")"
   
       
   
    mainSql = sql & sql2

    'db.execute (mainSql) ' INSERT THE HEADER
    'Call NxtOrdId("everydayfurnishings", "U") ' ADD the SEQUENCE
   
    AddORderHeader = "Order " & ORDR_NUMBER & " Placed Successfully."
   
   Else
   
    AddORderHeader = "Order is in the System Already"
   
   End If




Set db = Nothing
Set Rs = Nothing

End Function





and That is How i am Calling it in my ASP Page...


TT.AddORderHeader(CV , Items)

I also Tried

Call TT.AddORderHeader(CV , Items)

AB = TT.AddORderHeader(CV , Items)

TT.AddORderHeader CV , Items

but no Luck.

CV and Items are Arrays Like this within ASP Page. And i think it has something to do with Arrays.

Dim CV(50)
   
   
     CV(1) = "N"
     CV(2) = "1234"
... til 50

And..

    Dim Items(6, 0)
    Items(0, 0) = "114"
    Items(1, 0) = "12"
    Items(2, 0) = "12"
    Items(3, 0) = "12"
    Items(4, 0) = "1"
    Items(5, 0) = "11"
    Items(6, 0) = "11"

I am going Crazy, what is it that i am missing?
Please Help,.
0
Saqib Khan
Asked:
Saqib Khan
  • 4
  • 3
  • 3
  • +1
2 Solutions
 
EDDYKTCommented:
can you call from another vb app instead of from ASP?
0
 
EDDYKTCommented:
by the way

I don't see you use

Public Function AddORderHeader(ByVal OrderArray, ByVal Lines) As String

Lines from anywhere inside your function
0
 
leclairmCommented:
Have you tried changing your function parameters to arrays??

Public Function AddORderHeader(ByVal OrderArray() as string , ByVal Lines() as string ) As String
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
AzraSoundCommented:
Have you tried debugging the DLL to see where/when the error is actually occurring?
0
 
Saqib KhanSenior DeveloperAuthor Commented:
> can you call from another vb app instead of from ASP?

Yes, From VB it works just fine, in ASP it does not work.


I tried to Change from Array to String and it Works in ASP, when i just pass the Array name as parameter, it throws the nasty error in ASP.


yes i debugged and problem is caused because i am passing Array to this Function, as i said if i pass a string no problem.

Lines Parameter part i took out from the Function, because it has nothing to do with this issue.
0
 
AzraSoundCommented:
I believe the issue is actually trying to pass the array ByVal.  What if you do a ByRef parameter?
0
 
EDDYKTCommented:
0
 
AzraSoundCommented:
I knew this issue looked familiar...granted, that previous question is from 5+ years ago.   :-)
0
 
Saqib KhanSenior DeveloperAuthor Commented:
by changing to BYREF it solved the problem, now can you be kind enough and explain why did it work by changing to byRef, Funny thing is i have another function and it works just fine with byVal for ASP.

Thanks again guys.
0
 
AzraSoundCommented:
The "why" I'm not sure of, other than it is specific to arrays.  ByVal is not an issue with other data types passed between a VB COM dll and an ASP page.  Are you saying you pass an array ByVal elsewhere and it works fine?  If that's the case, then it is certainly a quirk.
0
 
Saqib KhanSenior DeveloperAuthor Commented:
> Are you saying you pass an array ByVal elsewhere and it works fine?

Yes, thats exactaly I mean, and that is why i been pulling my hair off the head. Seems like its a Issue with COM-ASP Array bug or something.

Thanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 3
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now