If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > saving

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-16-04, 14:51
Canada66_2002 Canada66_2002 is offline
Registered User
 
Join Date: Jan 2004
Posts: 15
saving

how can i save data from an asp page into a new entry in a microsoft access database
Reply With Quote
  #2 (permalink)  
Old 01-16-04, 16:18
jfunk jfunk is offline
Registered User
 
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 16:20.
Reply With Quote
  #3 (permalink)  
Old 02-03-04, 04:28
Bullschmidt Bullschmidt is offline
Guru
 
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
Reply With Quote
  #4 (permalink)  
Old 02-03-04, 11:48
gyuan gyuan is offline
Registered User
 
Join Date: Dec 2003
Posts: 454
"Beginning ASP Databases" is the book for you
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On