all groups > inetserver asp components > october 2006 >
You're in the

inetserver asp components

group:

passing correct value types from ASP/VBScript to VB/DLL


passing correct value types from ASP/VBScript to VB/DLL thisis
10/17/2006 1:13:47 PM
inetserver asp components:
Hi All,

I'm getting an error on my ASP page:

Microsoft VBScript runtime error '800a000d'
Type mismatch: 'StoreFileIntoField'

I assume - 99.5% - the error is generated because of worng value types,
I attemp to pass from my ASP/VBScript page to the VB/DLL function.

My relevant ASP/VBScript Code is:

<%
sTemp = "SomeStringOK"
mcsSQL = "select * from tbl1"

' creates an object ref to the VB/DLL function
Set obj = Server.CreateObject("SaveCreateFileADO.cStoreCreateFileADO")

' creates a ref' to my recordset object
Set rs = Server.CreateObject("ADODB.Recordset")

' openning the recordset with values of the string connection
rs.Open mcsSQL, mConn, 1, 3

With rs
..AddNew
If Not .EOF Then
'VB5: Dim fldFileName As ADODB.Field
'VB5: Set fldFileName = .Fields![sFileName] 'set reference to this
field
' vbscript:
Set fldFileName = rs("sFileName")

'VB5: Dim fldLongBinary As ADODB.Field
'VB5: Set fldLongBinary = .Fields![oPicture] 'set a reference to the
file field
' vbscript:
Set fldFileName = rs("oPicture")

rs("desc")= now() & "hello"

With obj
' call the VB/DLL
' THIS IS the line that generates the ERROR
If .StoreFileIntoField(rs, fldFileName, fldLongBinary, sTemp) Then
' do something End If
End With
End If
..Update
..Close
End With

%>

The Function in the VB/DLL is - returns a boolean value -
StoreFileIntoField(rs, fldFileName, fldLongBinary, sTemp)
suppose to get THESE values types:
rs VB5: As New ADODB.Recordset
fldFileName VB5: As ADODB.Field
fldLongBinary VB5: As ADODB.Field
sTemp VB5: As String

My Question is :

How do I pass the correct value types from ASP/VBScript to VB/DLL,
using this notion of ADO/ASP 2.0 syntex on PWS 4.0?
Re: passing correct value types from ASP/VBScript to VB/DLL Anthony Jones
10/18/2006 3:47:52 PM

[quoted text, click to view]

The signature of StoreFileIntoField will define typed byreference
parameters. The only data type that VBScript supports is variant hence the
only type that can be passed byref from VBScript is a variant.

You can do one of the following:-

1. Change StoreFileIntoField to accept variants
2. Change StoreFileIntoField to accept it's parameters ByVal (something I
recommend for most uses anyway even internally to VB6/5)
3. Place parenthesis around each argument e.g.;-

StoreFileIntoField((rs), (fldFileName), (fldLongBinary), (sTemp))

this turns each argument into an expression. Effectively causing them to be
passed ByVal.

Option 2 would be my preference.

Anthony.

Re: passing correct value types from ASP/VBScript to VB/DLL thisis
10/19/2006 6:34:37 AM
Anthony, Thanks for your answer, it's been great help!

[quoted text, click to view]
AddThis Social Bookmark Button