How to call a SQL-database with ASP - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How to call a SQL-database with ASP

PLEASE HELP ME,

We have to make a e-commerce site for a school project.
A have tried to make a connection to a sql database, but didn't work.

Could someone send me de script to connect the SQL-database. (a if you have more script that could be handy for us, please send it too)

Greetings


Comments

  • zeeshanzeeshan Posts: 22Member
    Here is sample code and steps that how to make a connection to SQL database


    1) Make a DSN to the database via ODBC that you want to access with ASP

    2) in your asp page write

    [blue]

    Dim dcnDB

    Set dcnDB = Server.CreateObject("ADODB.Connection")

    [red]
    [green]'dsn line to connect to database[/green]
    dcnDB.ConnectionString = "dsn=myDSN;uid=myUserID;Pwd=myPwd"
    [/red]
    dcnDB.Open

    Dim rs

    Set rs = dcnDB.Excute ("SELECT * FROM TableName")

    If rs.EOF = TRUE Then

    response.write "no record found"

    else


    DO While Not rs.EOF = TRUE

    for each field in rs
    response.write field.name
    response.write " "
    response.write field.value
    next

    rs.MoveNext
    loop

    end if

    set rs = nothing

    dcnDB.Close
    set dcnDB = Nothing
    [/blue]


    please check this code or if this doesn't solve ur prob do let me now...


    : PLEASE HELP ME,
    :
    : We have to make a e-commerce site for a school project.
    : A have tried to make a connection to a sql database, but didn't work.
    :
    : Could someone send me de script to connect the SQL-database. (a if you have more script that could be handy for us, please send it too)
    :
    : Greetings
    :
    :
    :

    [blue][b]Zeeshan Arshad[/b][/blue]
    [red]Web Developer[/red]
    [green]http://zeeshan.smashglobal.com/[green]

Sign In or Register to comment.