Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Posts
    202

    Unanswered: How to use sql server

    When i connect to SQL server from ASP, i could get through but i kindda of not sure how to use it.
    Could you pls help me and show me the coding to use it.

    My coding when i connect to SQL server from ASP:

    Dim conn,strSQL,rs

    set conn=Server.CreateObject("ADODB.Connection");
    conn.ConnectionString="driver={SQL Server};"&_............
    ..................

    strySQL="Select empName from employee"
    set rs=Server.CreateObject("ADODB.Recordset")
    conn.Open
    rs.Open strSQL,conn

    Maybe you could show me how to save something into the database.
    any field given.
    Thanx
    Last edited by michaelfg81; 03-28-04 at 21:47.

  2. #2
    Join Date
    Dec 2003
    Location
    Delhi INDIA
    Posts
    58
    declare one more variable in your asp script and change the strySQL code like the below,

    Dim val
    Dim conn,strSQL,rs

    set conn=Server.CreateObject("ADODB.Connection");
    conn.ConnectionString="driver={SQL Server};"&_............
    ..................

    strySQL="insert into employee values('& val &')"

    set rs=Server.CreateObject("ADODB.Recordset")
    conn.Open
    rs.Open strSQL,conn



    'try it......
    Deep..

    MCDBA
    ------------------------------------------
    How much data you can afford to lose??

  3. #3
    Join Date
    Aug 2002
    Location
    Scotland
    Posts
    1,578
    --Satya SKJ
    Microsoft SQL Server MVP
    [IMG]http://sqlserver-qa.net/google_bart.gif[/IMG]

  4. #4
    Join Date
    Oct 2003
    Location
    Slovakia
    Posts
    21
    try this code:

    Dim conn,strSQL,rs

    set conn=Server.CreateObject("ADODB.Connection");
    conn.ConnectionString="driver={SQL Server};"&_............
    ..................

    strySQL="Select empName from employee"
    set rs = conn.execute(strySQL)
    .
    .
    .
    and it returns the recordset to rs variable...then you can get data from rs like this:

    do while not rs.EOF
    Response.Write rs(0)
    rs.movenext
    loop

    write if it works for you...
    wuadko

Posting Permissions

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