Ok,

Try the following. This works for me, all other routes seem to fall over :-(

- Use a "?" to substitute for each subroutine argument
- Create an ADODB parameter for each argument
- Set the value of the ADODB parameter
- Append that parameter to the command Parameters collection

NOTE: Using the ADODB.Command.CreateParameter does NOT seem to work with
UniOleDB.

Assuming that dbConn is an open UniOleDB connection, this calls a subroutine
SelectTitle (similar to the one I posted before) in VB - and should work the
same in VBScript:

    Dim dbParam As ADODB.Parameter
    Dim dbCmd As ADODB.Command      

    ' Set the command to point to the SelectTitle subroutine
    Set dbCmd = CreateObject("ADODB.Command")
    dbCmd.ActiveConnection = dbConn
    dbCmd.CommandText = "CALL SelectTitle(?)"
    
    ' Create an unnamed parameter to substitute.
    Set dbParam = CreateObject("ADODB.Parameter")
    dbParam.Type = adBSTR    
    dbParam.Value = Text1.Text
    dbCmd.Parameters.Append dbParam
    
    ' Execute and display results. RecordCount is -1 if data is found.
    Set dbRS = dbCmd.Execute
    If dbRS.RecordCount <> 0 Then
       dbRS.MoveFirst
       Do
        List1.AddItem dbRS.Fields("TITLE")
        dbRS.MoveNext
       Loop Until dbRS.EOF
    End If
 
Hope this helps,

Brian

> This is exactly what I wantto do. However the VBScript syntax 
> is where I'm getting stuck. How do I set the arguments... I 
> know with uvobj sub calls you need to set the parameter 
> values for the routine. I'm assuming the same is true here. 
> But this is what I have :
> 
>       dim cnn
>       set cnn = Server.CreateObject("ADODB.Connection")
>       cnn.Provider = "IBM.UniOLEDB.1"
>       dim dns
>       dsn = "DATA SOURCE=localuv;LOCATION=test;USER 
> ID=test;PASSWORD=test;"
>       cnn.Open(dsn)
>       dim rs, sql
>       set rs = server.createobject("adodb.recordset")
>         txtSubroutine = "MYSUB"
>       SQL = "{CALL """ & txtSubroutine & "}"
>         rc = cnn.Execute (SQL)
> 
> 
> 
> 
> but my sub has arguments that need to be passed. I'm sure I'm 
> looking right at the answer and looking right over it.
> 
> Vance
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to