Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2004

    Unanswered: Regarding the Adding of a records

    Hello Members

    I want to know how to add the records into MSSQL 2000 through ASP pages.

    I also need to know how to show the same records I have added.

    N.B. : IF the code snippet can be provided then it is highly appriciated.

    Praveen Kumar Pandey

    CoVisible Solutions, The Ultimate Outsourcing Channel

  2. #2
    Join Date
    Jul 2003
    There are a ton of tutorials online for exactly this.. but the basic idea is this:

    <ServerAddress> = IP or DNS address to SQL server
    <Database> = DB name on the SQL server to connect to
    <DBUser> = Username that has access to the DB
    <DBPassword> = Password for username

    "myTable" = The table you want to quey
    "Column1" = The name of the column you want to return

    <!-- #include virtual="inc-adovbs.asp" -->
    Dim strDBConn, sSQL 
    Dim objDataCmd, objconn, objrs 
    sDBConn="Provider=SQLOLEDB; Data Source=<ServerAddress>; Initial Catalog=<Database>; User Id=<DBUser>; Password=<DBPassword>; Network Library=DBMSSOCN"
    set objDataCmd = server.CreateObject("ADODB.Command")
    set objconn = server.CreateObject ("ADODB.connection")
    set objrs = server.createObject("ADODB.recordset")
    objconn.Open sDBConn
    objDataCmd.ActiveConnection = objconn
    sSQL = "SELECT * FROM myTable"
    objDataCmd.CommandText = sSQL
    set objrs = objDataCmd.Execute ( , ,adCmdText)
    If NOT objrs.BOF AND NO objrs.EOF Then
      While NOT objrs.EOF
        Response.Write objrs("Column1") & "<BR>"
    End If
    set objrs = Nothing
    set objconn = Nothing
    set objDataCmd = Nothing
    You'll need the attached include file.
    That which does not kill me postpones the inevitable.

Posting Permissions

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