Results 1 to 4 of 4

Thread: recordsets...

  1. #1

    Thread Starter
    Fanatic Member wildcat_2000's Avatar
    Join Date
    Nov 2000
    Location
    Italy
    Posts
    727

    recordsets...

    hi all,

    apparently i'm losing it here... i can't declare a recordset and have a normal usage of these.

    in ASP.OLD i used:
    Code:
    Dim StrConnect as String
    Dim Rs As ADODB.Recordset
    
    StrConnect = "Provider=Microsoft.Jet.OLEDB.4.0; " & _
        "Data Source=c:\inetpub\wwwroot\mysite\database\mysite.mdb"
    Rs=Createobject("Adodb.Recordset")	'connection to DB
    Stropen="Select * FROM cmodc_login WHERE (Active AND iduser='" & iduser & "')"
    
    Rs.Open StrOpen,StrConnect,3,3
    
    if NOT Rs.eof then
        do while not Rs.EOF
            Response.Write(Rs("idname"))
            Rs.MoveNext
        loop
    end if
    Rs.close
    
    'free memory
    Set Rs=nothing
    ...can someone point me in the direction of how the code would look like in asp.net...?

    thanks...

    wc.
    When your car breaks down,
    close all windows and retry

    => please rate all users posts! <=

  2. #2

    Thread Starter
    Fanatic Member wildcat_2000's Avatar
    Join Date
    Nov 2000
    Location
    Italy
    Posts
    727
    i finally managed using the datareader class, here's an example for anyone who needs it.

    VB Code:
    1. Dim StrConnect as String, StrOpen as string
    2. Dim DBconn As OleDbConnection, DBcomm as OleDbCommand, DBread as OleDbDataReader
    3.  
    4. 'connect
    5. StrConnect = "Provider=Microsoft.Jet.OLEDB.4.0; " & _
    6.    Data Source=c:\inetpub\wwwroot\mysite\database\mysite.mdb"
    7.  
    8. DBconn=New OleDbConnection(StrConnect)  'connection to DB
    9. DBconn.Open()
    10.  
    11. Stropen="Select * FROM cmodc_login WHERE (Active AND iduser='" & iduser & "')"
    12. DBcomm=New OleDbCommand(Stropen,DBconn)
    13. DBread=DBcomm.ExecuteReader()
    14.  
    15. If DBread.Read then
    16.     'the datareader contains a resultset.
    17.     Response.Write DBread("idname")
    18. End If
    19. DBconn.close()
    20.  
    21. 'free memory
    22. DBconn = nothing
    23. DBread = nothing

    only, still not sure how to LOOP this...
    When your car breaks down,
    close all windows and retry

    => please rate all users posts! <=

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Originally posted by wildcat_2000


    only, still not sure how to LOOP this...
    While DBread.Read()

  4. #4

    Thread Starter
    Fanatic Member wildcat_2000's Avatar
    Join Date
    Nov 2000
    Location
    Italy
    Posts
    727
    thank you
    When your car breaks down,
    close all windows and retry

    => please rate all users posts! <=

Posting Permissions

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



Click Here to Expand Forum to Full Width