Assigning ASP variable to VB component recordset???

Results 1 to 2 of 2

Thread: Assigning ASP variable to VB component recordset???

  1. #1
    Join Date
    Dec 1969
    Posts
    170

    Default Assigning ASP variable to VB component recordset???

    Could someone please help me with a code sample that shows how to return a recordset to an asp variable from a VB component? I&#039ve found the code for getting a recordset directly, but I want to hide my access code by using a dll on the server. <BR><BR>I have written a VB 6 dll with a function that retrieves a recordset from SQL. I have tried dimming the function as ADODB.recordset and have also tried just placing a byref variable in the function of type ADODB.Recordset. I&#039m missing something here. <BR><BR>Thanks!<BR><BR>Julie

  2. #2
    Twizted Guest

    Default RE: Assigning ASP variable to VB component recordset???

    Here is the VB DLL part of the code (you will need to open the connection, etc.)<BR><BR>Public Function GetRecords() As Variant<BR>&#039Purpose: Retrieve a recordset<BR><BR> On Error GoTo GetRecordsError<BR> Dim strSQL As String<BR><BR> &#039Check the state of the connection<BR> &#039and load the recordset<BR> If IsOpen Then<BR> strSQL = "SELECT * FROM authors "<BR><BR> Set GetRecords = mcnnDB.Execute(strSQL)<BR> End If<BR> Exit Function<BR><BR>GetRecordsError:<BR> GetRecords = Err.Description<BR>End Function<BR><BR>ASP side:<BR>&#060;%<BR><BR> &#039Create object instance<BR> Set objDB = Server.CreateObject("MyDLL.DBStuff")<BR> Set rstResults = Server.CreateObject("ADODB.Recordset")<BR><BR> &#039Open database connection and retrieve records<BR> objDB.OpenConnection<BR> Set rstResults = objDB.GetRecords<BR><BR> If Not rstResults.BOF Then<BR> &#039Same code to build table here<BR> <BR> Response.Write(rstresults.Fields("colname"))<BR> <BR> End If<BR><BR> &#039Clean up<BR> Set rstResults = Nothing<BR> objDB.CloseConnection<BR> Set objDB = Nothing<BR><BR>&#037;&#062;<BR><BR>-TwIzTeD

Posting Permissions

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