473,473 Members | 1,847 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem inserting record into Access database

Hi,

I have searched everywhere, and I can't seem to find the answer to my
problem. I am trying to write a very simple piece of ASP code to
insert a record into a field in a database. Ultimately it will be for
an admin form that takes user input, but for now I just want to get
the most intrinsic part working. This is the code:

<% ' Declare variables
Dim strURL ' The URL of this page so the form will work no matter
what this file is named.
Dim myConn ' ADO connection
Dim strDBPath ' path to our Access database (*.mdb) file
Dim strSQL ' The query string
Dim strSummary ' The summary string

' Fill in value for strSummary, it doesnt really matter what it is
strSummary = "blahblah"

' Retreive the URL of this page from Server Variables
strURL = Request.ServerVariables("URL")

' MapPath of virtual database file path to a physical path.
strDBPath = Server.MapPath("dvd_club.mdb")

'Create the ADO object
Set myConn = Server.CreateObject("ADODB.Connection")

' Create an ADO Connection to connect to the database.
Set cnnSearch = Server.CreateObject("ADODB.Connection")

myConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
strDBPath & ";"
' Add movie summary to database
strSQL = "INSERT INTO Results (dvdSummary) VALUES ('"strSummary"');"

myConn.Execute(strSQL)
myConn.Close
Set myConn = Nothing %>

This just yields an HTTP 500 internal server error. When I open the
database table in Access, it is not updated. Does anyone know what I
am doing wrong?

Thanks,
Erica
Nov 12 '05 #1
1 2012
> ' Add movie summary to database
strSQL = "INSERT INTO Results (dvdSummary) VALUES ('"strSummary"');"

myConn.Execute(strSQL)
myConn.Close
Set myConn = Nothing %>


shouldn't the strSQL line be something like:

strSQL = "INSERT INTO Results (dvdSummary) VALUES ('" & strSummary &
"');"

since you're building the SQL string on the fly? You should probably
do a Response.Write strSQL so you can see what the server is trying to
execute. If you copy that into a QBE grid in Access, and it doesn't
compile then there's your problem.
Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Erica | last post by:
Hi, I have searched everywhere, and I can't seem to find the answer to my problem. I am trying to write a very simple piece of ASP code to insert a record into a field in a database. Ultimately...
3
by: Surya | last post by:
Dear All, I have problem on inserting a record to database..Although it looked easy.. i have caught up with following issue .. please go ahead and help me to find solution I Need to insert...
20
by: dav3 | last post by:
Alright folks I am in need of a lil guidance/assistance here. I have a program which reads in a txt file. This txt file contains lines of the form January 3, 2007, 85.8 Now each line of the txt...
2
by: hakkatil | last post by:
Hi to all, I have a page that inserts excel sheet to access database. I am using asp. What I want to do is to check the inserting record if it is in the database. Basicly checking the dublicate...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.