Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.