Syntax to Display Results on Web Page

Discussion in 'C#' started by septemberq, Apr 28, 2008.

  1. #1
    Hello and Thank you

    I need to Script a db “Query Results” Web Page.
    My scripting skill is basic.

    I am working with: Classic ASP / VBScript / MS SQL / 3rd Party Shared Sever

    I already have : A Two Field Query Form, A db Connection String in a “include” file and A Query String

    I need help with the ASP script & syntax to: Display Results on Web Page,

    Many Thanks
     
    septemberq, Apr 28, 2008 IP
  2. MayurGondaliya

    MayurGondaliya Well-Known Member

    Messages:
    1,233
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    170
    #2
    What exactly do you want to do? Do you want to just display the values that you fetch using the query strings? If yes then why you want the db functionality. Or do you want to just add that two fields into the db or want to search the db using that two fields and display the result(or selected row)? please elaborate.
     
    MayurGondaliya, Apr 29, 2008 IP
    septemberq likes this.
  3. septemberq

    septemberq Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you for responding
    Here is what I want to do : Search the db using the two fields and display the results.
     
    septemberq, Apr 30, 2008 IP
  4. MayurGondaliya

    MayurGondaliya Well-Known Member

    Messages:
    1,233
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    170
    #4
    Try with the below code. You will need to modify this code according to your table schema and page elements.

    <%
    DIM strconnectiostring, objConn, objRecordset
    
    Set objConn = Server.CreateObject("ADODB.Connection")
    
    strDataSourceName="Provider=sqloledb;Data Source=YOURDATABASESERVER,1433;Network Library=DBMSSOCN;Initial Catalog=YOURDATABASENAME;User ID=DATABASEUSERNAME;Password=DATABASEPASSWORD;"
    
    objConn.connectionstring = strconnectiostring
    
    
    Set objRecordset = Server.CreateObject("ADODB.Recordset")
    
    objConn.Open
    rs.open "select * from TABLENAME where field1 = querystring1 and field2=querystring2"
    
    ' suppose there are 5 fields
    
    Response.write(str(rs(0)))
    Response.write(str(rs(1)))
    Response.write(str(rs(2)))
    Response.write(str(rs(3)))
    Response.write(str(rs(4)))
    
    
    %>
    Code (markup):
     
    MayurGondaliya, Apr 30, 2008 IP
  5. septemberq

    septemberq Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thank you
    I'll keep you posted
     
    septemberq, Apr 30, 2008 IP
  6. septemberq

    septemberq Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    = =
    I modified the code and ran a successful test.
    
    <%
    Dim MM_sql_conn_info_STRING
    dim conn_uid, conn_pwd,conn_machine,conn_dbname
    
    conn_uid = "userid"
    
    conn_pwd = "password"  
    
    conn_machine = "000.000.000.000" 
    
    conn_dbname = "dbname"
    
    MM_sql_conn_info_STRING = "Provider=SQLOLEDB.1;Persist Security Info=False;uid=" & conn_uid & ";pwd=" & conn_pwd & ";Initial Catalog=" & conn_dbname & ";Data Source=" & conn_machine & ";"
    
    set conn = CreateObject("ADODB.Connection") 
        conn.open MM_sql_conn_info_STRING
    
      ' Test connection
      '---------------------------------------------
      Set oRs = conn.Execute("SELECT * FROM TABLENAME;")
    
      If Not oRs.EOF Then
       Do While Not oRs.EOF
        Response.Write oRs(0) & "<br>"
       oRs.MoveNext
       Loop
      End If
    %>
    
    Code (markup):
    I now need some guidance to structure; QUERY, FORM, RESULTS
    Thanks for your help
     
    septemberq, May 1, 2008 IP
  7. septemberq

    septemberq Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    All done.
    Many thanks.
     
    septemberq, May 2, 2008 IP