Results 1 to 4 of 4

Thread: saving

  1. #1
    Join Date
    Jan 2004
    Posts
    15

    Unanswered: saving

    how can i save data from an asp page into a new entry in a microsoft access database

  2. #2
    Join Date
    Nov 2003
    Location
    Canada
    Posts
    14
    Not a simple answer to this one!!

    1. Have you set up a DSN to link to your database?
    2. If not #1, are you planning on using a DSN-less connection (a good idea if your web application is expecting a lot of hits or is on your ISP's sever - ISP's may frown on having to set up and maintain your own DSN's).
    3. You have to set up a connection to your database, a sample of code you may wish to use is displayed below:

    *****************************
    dim dbMyConnection
    dim rstMyTable
    dim strSQL
    set dbMyConnection = Server.CreateObject("ADODB.Connection")
    set rstMyTable = Server.CreateObject("ADODB.Recordset")

    MyConnection.Open "Data Source=" & Server.MapPath("Mydatabase.mdb") & ";Provider=Microsoft.Jet.OLEDB.4.0;"

    strSQL = "Select * From [MyTable]"
    rstMyTable.Open strSQL, dbMyConnection, adOpenStatic, adLockOptimistic

    rstMyTable.AddNew
    rstMyTable("Field 1") = "My First Data"
    rstMyTable.Update

    rstMyTable.Close
    dbMyConnection.Close

    *****************************
    The above snippet of code is just a guideline. Try it out and modify table and variable names to suit your own needs.

    P.S. Make sure that you create an include at the beginning of your ASP page that includes the "adovbs.inc" file if you are going to be using constants like "adOpenStatic" and "adLockOptimistic" instead of their numerical counterparts.

    Let me know how you make out with this.
    Last edited by jfunk; 01-16-04 at 17:20.

  3. #3
    Join Date
    Jun 2003
    Location
    USA
    Posts
    1,032
    Also the Samples area at www.asp101.com has some good, short database adding and editing examples.
    J. Paul Schmidt, Freelance Web and Database Developer
    www.Bullschmidt.com
    Access Database Sample, Web Database Sample, ASP Design Tips

  4. #4
    Join Date
    Dec 2003
    Posts
    454
    "Beginning ASP Databases" is the book for you

Posting Permissions

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