Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2009
    Posts
    2

    Question Unanswered: Connect to sql db vbscript in ASP

    Good day,

    Need to connect & retrieve from SQL DB in aspx page using vbscript server side

    I have an html page which I want to edit by adding information from a SQL database & display results on and in the html page (code below).

    Any code would be great that works in the aspx page where i can just insert the DB connection details & sql statement & display the result on page.

    Please Assist

  2. #2
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,477
    Provided Answers: 11
    it can't be done in HTML
    HTML is DUM all it does to format and display the DATA


    Code:
    Dim connstring   'conection string
    Dim rs   'recordset name
    Dim SQL   'sql
    Dim my_Conn
    set my_Conn = Server.CreateObject("ADODB.Connection")
    set connstring = Server.CreateObject("ADODB.Connection")
    
    connstring.Open "Provider=SQLOLEDB; Data Source = (local); Initial Catalog = #####;User Id =####; Password=######"
    if you save as a inc file

    at the top of the ASP pages
    <!-- #include file="inc/adovbs.inc" -->
    <!--#include file="inc/opendb.inc"-->

    mine is called opendb.inc and its in the inc folder.

    now get the DATA

    1st create a record object
    Set Rs = Server.CreateObject("ADODB.Recordset")
    2 create the SQL
    SSQL = ""
    SSQL = SSQL & "SELECT [Note to PDF Sum].* FROM [Note to PDF Sum]"
    3 open the SQL or table must be sql statment
    Rs.Open SSQL, connstring, adOpenKeyset, adLockPessimistic, adCmdText
    4 now we can do some thing

    do until rs.eof
    ...
    ..
    ..
    rs.movenext
    loop
    rs.close
    set rs = nothing
    hope this help

    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.
    DONT WORRY ABOUT THOSE WHO TALK BEHIND YOUR BACK
    THEY'RE BEHIND YOU FOR A REASON

  3. #3
    Join Date
    Apr 2009
    Posts
    2

    Wink

    Thanks a million for the help, really apprecaite it.

    I have been struggling for a while, the ascs page displays the as text but not the results from the query, i thought of a workaround creating a report - with a iframe in the header with not borders & the page look's like one.


    Thank You

  4. #4
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,477
    Provided Answers: 11
    yeap that can be done but you must walk before u run
    iframe will do the job but that hard once you under stand part1 then play around with part 2 ok.
    hope this help

    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.
    DONT WORRY ABOUT THOSE WHO TALK BEHIND YOUR BACK
    THEY'RE BEHIND YOU FOR A REASON

Posting Permissions

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