View Complete Thread
  • Problem displaying database info on page

    Aug 13, 2005 02:06 PM|jforward5|LINK

    I am having problems getting the information in my sql database to display on my webpage.  I can't use the SQLDataAdapter wizard to link up to my data because my web host doesn't allow remote access in that way.  So I created a recordset connection object and used it to connect to the database.  This works fine in manipulating the information and validating it, but i can't get it to display the information I pick with the SELECT command.  Everytime I try to call the info from the recordset to the page it shows the name and type of object i have created instead of the information I selected.  Here is an example of the code I am using to make the connection:

    Dim oConn, oRs
    Dim qry, connectstr
    Dim db_name, db_username, db_userpassword
    Dim db_server
    Dim fieldname, tablename

    db_server = "myserver_Location/name_here"
    db_name = "my_dbname"
    db_username = "my_dbusername"
    db_userpassword = "my_dbpassword"
    fieldname = "my_field"
    tablename = "my_table"

    connectstr = "Driver={SQL Server};SERVER=" & db_server & ";DATABASE=" & db_name & ";UID=" & db_username & ";PWD=" & db_userpassword

    Set oConn = Server.CreateObject("ADODB.Connection")
    oConn.Open connectstr

    qry = "SELECT * FROM " & tablename

    Set oRS = oConn.Execute(qry)

    if not oRS.EOF then
    while not oRS.EOF
    response.write ucase(fieldname) & ": " & oRs.Fields(fieldname) & "
    "
    oRS.movenext
    wend
    oRS.close
    end if

    Set oRs = nothing
    Set oConn = nothing


    The response line is supposed to show me the information i selected, however it doesn't.  I am using vb to program this.  Can some one please help me with this?[:)]

    Thanks
    http://www.crackerjacksoftware.com
    CrackerJack Software, we solve computer problems!