Passing arguments to VB function from ASP

Results 1 to 2 of 2

Thread: Passing arguments to VB function from ASP

  1. #1
    droy Guest

    Default Passing arguments to VB function from ASP

    I&#039;m having problems passing 2 arguments from an ASP page to a VB function. I can pass the arguments if I hardcode them, but when I try to pass them using variables, I get the following message:<BR><BR>Microsoft VBScript runtime error &#039;800a000d&#039; <BR>Type mismatch: &#039;GetList&#039; <BR>/xyz/test.asp, line 15 <BR><BR>ASP Code:<BR>-------------------------------<BR>iListId=1<BR>strSortOrder="email"<BR> <BR>Set objList=Server.CreateObject("ContactMgr.ListData") <BR>Set objRS=objList.GetList(iListId,strSortOrder)<BR>... <BR><BR>VB Function:<BR>-------------------------------<BR>Function GetList(listid As Integer, sortorder As String) As ADODB.Recordset<BR><BR>Dim cn As New Connection<BR>Dim cmd As New Command<BR>Dim rs As New Recordset<BR><BR><BR><BR>On Error GoTo HandleError:<BR><BR>cn.ConnectionString = "driver={SQL Server};server=xxxxx;uid=xxxxx;pwd=xxxxx;database= xxxxx"<BR>cn.Open<BR><BR>Set cmd.ActiveConnection = cn<BR>cmd.CommandText = "select * from v_GetEmailEditList where listid=" & listid & _<BR> " order by " & sortorder<BR>cmd.CommandType = adCmdText<BR><BR>Set rs = cmd.Execute()<BR><BR>Set GetList = rs<BR><BR>&#039;Set rs = Nothing<BR>&#039;Set cmd = Nothing<BR>&#039;cn.Close<BR>&#039;Set cn = Nothing<BR><BR><BR>HandleError:<BR> If Err.Number &#060;&#062; 0 Then<BR> Err.Raise Err.Number, Err.Source, Err.Description<BR> End If<BR> <BR> <BR>End Function<BR><BR> <BR>

  2. #2
    Robbe Guest

    Default RE: Passing arguments to VB function from ASP

    ASP variables are "variant" by default and would cause a type mismatch for COM object functions expecting a different data type than "variant". The simpliest option is to convert the ASP variant to a string<BR><BR> FunctionName(cstr(sFirstVariable),cint(nSecondVari able))

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts