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 Member Posts: 22
    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]

  • Justin BibJustin Bib USAMember Posts: 0

    __ / http://forcoder.org / free ebooks and video tutorials about < Objective-C, Assembly, Go, Scratch, JavaScript, Visual Basic .NET, MATLAB, Java, R, Perl, Ruby, Swift, PL/SQL, C++, C, C#, PHP, Python, Visual Basic, Delphi Awk, Julia, Scheme, Rust, Bash, VBScript, ABAP, Prolog, ML, Fortran, Logo, Dart, Ada, Scala, Crystal, Transact-SQL, Clojure, LabVIEW, F#, Apex, Lisp, Kotlin, SAS, COBOL, D, Alice, FoxPro, Erlang, Lua, Hack /> __

Sign In or Register to comment.