ASP Connecting to SQL 2005

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • StrykerNet
    New Member
    • Aug 2008
    • 13

    ASP Connecting to SQL 2005

    I need to create a dynamic landing page for my company using classic ASP. We have over 40 pages that we want to just have one template and have the page pull data from our DB and post the correct logo and services associated with that client on their page. I would appreciate any help I can get on this as I do not know hot to create the connectino to SQL or create the table neccessary to display the services and prices.
  • Dwagar
    New Member
    • Feb 2009
    • 6

    #2
    To have all the pages use the same files for a template you can use this.

    <!--#include file="header.as p"-->

    And put the html code in the header.asp file if you keep that name.

    Here is a connection string to get connected to the SQL database, if you need a database connection on all 40 pages I would put this in the header.asp file just in case if the database info changes you will only need to modify it once instead of 40 times.

    set DB=Server.Creat eObject("ADODB. Connection")
    DB.Open("Driver ={SQL Server};Server= 000.000.000.000 ;Database=DATAB ASENAME;UID=USE RNAME;PWD=PASSW ORD")

    Read a table and fields you can do by using the following.

    set RS=Server.Creat eObject("ADODB. RecordSet")
    RS.Open("SELECT * FROM Table",DB)
    response.write( RS("FieldName") )

    I hope this helps you get started.

    Comment

    Working...