Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access ASP
|
Access ASP Using ASP with Microsoft Access databases. For Access questions not specific to ASP, please use the Access forum. For more ASP forums, please see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access ASP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 8th, 2003, 08:38 AM
Registered User
 
Join Date: Oct 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default unable to insert records into access DB

I am trying guestbook.asp given in the ASP3.0 book in chapter 12.
ASP page is able to insert a new record. But when I open the Access
DB file I don't see any data in it other than an new record.

Please help me. I am using WinXP, Access2002.

Guestbook.mdb i downloaded from wrox site.

ASP page is this.
================
<%@ Language=VBScript %>
  <html>
  <head>
  <title>Guest Book Using Connection Object Only</title>
  </head>
  <body>

  <h2>Guest Book Using Connection Object Only</h2>
    <%
dbname="guestbook.mdb"
set conn=server.createobject("adodb.connection")
cnpath="DBQ=" & server.mappath(dbname)
'conn.mode = 3
conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " & cnpath
     'Get the data from the form. We will be inserting it into the database.
     'Access doesn't like some characters, such as single-quotes, so encode the
     ' data using the HTMLEncode method of the ASP Server object.
     dim strTB1, strTB2, strTB3, strTB4, strMB1, strCommand
     strTB1 = Server.HTMLEncode(Request.QueryString("From"))
     strTB2 = Server.HTMLEncode(Request.QueryString("EMailAdd"))
     strTB3 = Server.HTMLEncode(Request.QueryString("CC"))
     strTB4 = Server.HTMLEncode(Request.QueryString("Subject"))
     strMB1 = Server.HTMLEncode(Request.QueryString("Memo"))
     'This is a connection string. ADO uses it to connect to a database through the Access driver.
     'It needs the provider name of the Access driver and the name of the Access database.
     'Connection strings are slightly different, depending on the provider being used,
     ' but they all use semicolons to separate variables.
     'If this line causes and error, search in your registry for
     ' Microsoft.JET to see if 4.0 is your version.
'strProvider = "Provider=Microsoft.JET.OLEDB.4.0;Data 'Source=C:\InetPub\Wwwroot\Tutorial\guestbook.mdb; "
     'This creates an instance of an ADO Connection object.
     'There are 4 other ADO objects available to you, each with different methods and
     'properties that allow you to do almost anything with database data.
     Set objConn = server.createobject("ADODB.Connection")
     'The Open method of the Connection object uses the connection string to
     ' create a connection to the database.
     'objConn.Open strProvider
     'response.Write strTB1 & & strTB2 & & strTB3 & & strTB4 & & strMB1 & <br>
     'Define the query.
     'There are many types of queries, allowing you to add, remove, or get data.
     'This query will add your data into the database, using the INSERT INTO key words.
     'Here, GuestBook is the name of the table.
     'You need single-quotes around strings here.
     strCommand = "insert into GuestBook (FTB1,FTB2,FTB3,FTB4,FMB1) VALUES ('"
     strCommand = strCommand & strTB1 & "','" & strTB2 & "','" & strTB3 & "','" & strTB4 & "','" & strMB1
     strCommand = strCommand & "')"
     'Execute the query to add the data to the database.
     conn.Execute strCommand
     Const ForWriting = 2
Const Create = True
     Response.Write("Thank you! Your data has been added.")
conn.close
set conn=nothing
  %>

  </body>
  </html>

TIA
Sree





Similar Threads
Thread Thread Starter Forum Replies Last Post
Access DB Records Randomly becomes Chinese scripter Access VBA 3 May 3rd, 2006 05:19 AM
unable to insert records into database everest Classic ASP Databases 11 March 22nd, 2004 02:28 PM
Unable to INSERT INTO db nvillare Classic ASP Databases 6 August 26th, 2003 10:29 AM
Insert Command Refused by Access DB hoffmann Classic ASP Databases 1 July 31st, 2003 08:49 PM
Filtering records from Access DB andy24 Classic ASP Databases 1 July 22nd, 2003 08:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.