im trying to add form data in to my local sql 2005 database but having a lot of trouble. I have searched the web but im coming across misleading information time and time again.
below is my code -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml">
-
<head>
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-
<title>Submit Document</title>
-
</head>
-
<body>
-
<%
-
Set conn = Server.CreateObject("ADODB.Connection")
-
objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
-
Server.MapPath ("laptop\omar.mdb") & ";"
-
objConn.Open
-
-
sql="INSERT INTO webform (txtAmount,txtPurpose,"
-
sql=sql & "txtResidentialStatus,txtTitle,txtFirstName,txtSurname,txtContactNumber,txtEveningNumber,txtEmailAddress)"
-
sql=sql & " VALUES "
-
sql=sql & "('" & Request.Form("txtAmount") & "',"
-
sql=sql & "'" & Request.Form("txtPurpose") & "',"
-
sql=sql & "'" & Request.Form("txtResidentialStatus") & "',"
-
sql=sql & "'" & Request.Form("txtTitle") & "',"
-
sql=sql & "'" & Request.Form("txtFirstName") & "',"
-
sql=sql & "'" & Request.Form("txtSurname") & "',"
-
sql=sql & "'" & Request.Form("txtContactNumber") & "')"
-
sql=sql & "'" & Request.Form("txtEveningNumber") & "')"
-
sql=sql & "'" & Request.Form("txtEmailAddress") & "')"
-
-
on error resume next
-
conn.Execute sql,recaffected
-
if err<>0 then
-
Response.Write("No update permissions!")
-
else
-
Response.Write("<h3>" & recaffected & " record added</h3>")
-
end if
-
conn.close
-
%>
-
-
-
</body>
-
</html>
-
can some one help please?
7 1574 ck9663 2,878
Recognized Expert Specialist
1. What's the error that you're getting?
2. Display the value of the your sql variable and paste it to your query analyzer. See what error will show up.
-- CK
this is what i'm getting on the next page
<% Set conn = Server.CreateOb ject("ADODB.Con nection") ConnectionStrin g = "Provider = SQLNCLI;" & _ "Data Source = LAPTOP\\SQLEXPR ESS;" & _ "Initial Catalog = zion.mdb;" & _ "User ID = ej2_sleeper;" & _ "Password = jennifer1;" Server.MapPath ("laptop\omar.m db") & ";" conn.Open txtAmount = Trim(Request.Fo rm("txtAmount") ) txtPurpose = Trim(Request.Fo rm("txtPurpose" )) txtResidentialS tatus = Trim(Request.Fo rm("txtResident ialStatus")) txtTitle = Trim(Request.Fo rm("txtTitle") ) txtFirstName = Trim(Request.Fo rm("txtFirstNam e")) txtSurname = Trim(Request.Fo rm("txtSurname" )) txtContactNumbe r = Trim(Request.Fo rm("txtContactN umber")) txtEveningNumbe r = Trim(Request.Fo rm("txtEveningN umber")) txtEmailAddress = Trim(Request.Fo rm("txtEmailAdd ress")) sql="INSERT INTO dbo.tbl_custome r (txtAmount,txtP urpose,txtResid entialStatus,tx tTitle,txtFirst Name,txtSurname ,txtContactNumb er,txtEveningNu mber,txtEmaildd ress)" sql=sql & " VALUES ('"&txtAmount&" ','"&txtPurpose &"', '"&txtResidenti alStatus& "','"&txtTitle& "','"&txtFirstN ame&"','"&txtSu rname&"','"&txt ContactNumber&" ', '"&txtEveningNu mber&"', '"&txtEailAddre ss&"')" conn.execute(sq l) 'if err<>0 then ' Response.Write err.Description 'else ' Response.Write( "
record added
") 'end if conn.close %>
not sure how to respond to your 2nd point as I dont understand..
ck9663 2,878
Recognized Expert Specialist
Do something like:
Response.Write( sql)
It will display the sql text. Copy the entire text and open a query window. Paste it on the query window and execute it. It'll give you detailed information on the error.
-- CK
hi CK thanks for your reply
i have modified my code according to your suggestion - but I still get all this info displayed on the page? below is updated code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Submit Document</title>
</head>
<body>
<%
Set conn = Server.CreateOb ject("ADODB.Con nection")
ConnectionStrin g = "Provider = SQLNCLI;" & _
"Data Source = LAPTOP\\SQLEXPR ESS;" & _
"Initial Catalog = zion.mdb;" & _
"User ID = ej2_sleeper;" & _
"Password = jennifer1;"
Server.MapPath ("laptop\omar.m db") & ";"
conn.Open
txtAmount = Trim(Request.Fo rm("txtAmount") )
txtPurpose = Trim(Request.Fo rm("txtPurpose" ))
txtResidentialS tatus = Trim(Request.Fo rm("txtResident ialStatus"))
txtTitle = Trim(Request.Fo rm("txtTitle") )
txtFirstName = Trim(Request.Fo rm("txtFirstNam e"))
txtSurname = Trim(Request.Fo rm("txtSurname" ))
txtContactNumbe r = Trim(Request.Fo rm("txtContactN umber"))
txtEveningNumbe r = Trim(Request.Fo rm("txtEveningN umber"))
txtEmailAddress = Trim(Request.Fo rm("txtEmailAdd ress"))
sql="INSERT INTO dbo.tbl_custome r (txtAmount,txtP urpose,txtResid entialStatus,tx tTitle,txtFirst Name,txtSurname ,txtContactNumb er,txtEveningNu mber,txtEmaildd ress)"
sql=sql & " VALUES ('"&txtAmount&" ','"&txtPurpose &"', '"&txtResidenti alStatus& "','"&txtTitle& "','"&txtFirstN ame&"','"&txtSu rname&"','"&txt ContactNumber&" ', '"&txtEveningNu mber&"', '"&txtEailAddre ss&"')"
conn.execute(sq l)
if err<>0 then
Response.Write( sql)
else
Response.Write( "<h3> record added</h3>")
end if
conn.close
%>
</body>
</html>
ck9663 2,878
Recognized Expert Specialist
Check your connection string. Here are more about it.
-- CK
thanks CK - maybe my connection string is incorrect after all. I've checked the site but not sure which string to use;
Providers to use when connecting to SQL Server 2005
» .NET Framework Data Provider for SQL Server (SqlConnection)
» SQL Native Client 9.0 OLE DB provider
» .NET Framework Data Provider for OLE DB (OleDbConnectio n)
» SQL Server Native Client 10.0 OLE DB Provider
» SQL Native Client 9.0 ODBC Driver
» SQL Server Native Client 10.0 ODBC Driver
» .NET Framework Data Provider for ODBC (OdbcConnection )
» SQLXML 4.0 OLEDB Provider
» Context Connection
I'm using SQL 2005 express with classic ASP on my vista laptop if that helps. Just trying to populate a table in my local SQL database via a local html webform.
please advise and many thanks in advance :)
ck9663 2,878
Recognized Expert Specialist
SQL Server family can be access by using the same connection string. Try one of these. You're doing it right using classic ASP.
Also, I'm not responding on your other post. Your insert on your other post will not work until you make your connection work.Try to make your connection work first, then do some simple SELECT. Then proceed to INSERT.
-- CK
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: cricketunes |
last post by:
Hi folks,
this one's had me stumped!
$conn=ora_logon("cricketunes@pickles","j8j3kf");
if ($conn != TRUE)
die("Unable to connect to oracle, exiting...\n");
$cursor = ora_open($conn);
if ($cursor != TRUE)
die("Unable to open a cursor, exiting...\n");
|
by: Mike M |
last post by:
Hi all,
I ahve the following SQL string but when i try to response.Write it there is
a error where the ',' should be between "city" and "County"
SQL = "INSERT * INTO customers (Company_Name, Category, Contact_Name,
Contact_Title, Address_1, Address_2, City, County, Post_Code, Phone_1,
Phone_2, Fax, Web_URL, email_Address, Delivery, Notes)"
SQL = SQL & " VALUES('" & Request.Form("Company_Name") & "','" &
|
by: Simom Thorpe |
last post by:
Hi,
I'm trying to insert a line into a MS access DB using ASP on IIS 5.
This is the line:
con.execute "INSERT INTO newProds(title,desc,catcode) VALUES
('Champagne Muff Scarf','','AC304B')"
But it throws up this error:
|
by: Jim |
last post by:
Im getting way too many rows retured..what its trying to do is insert
a 0 for revenue for months 7 - 12 (aka July through December) for each
of these cost centers for each payor type..Im getting a lot of repeats
and the concatenation field date always comes back as January 2003
instead of the month and date its supposed to
--Fiscal Year
|
by: Chris Geerdink |
last post by:
combo with PHP. what is wrong with the Javascript?
else
{
include("mysql.php");
$query1 = mysql_query("INSERT INTO gbook (naam, email, text) VALUES
('".$_POST."', '".$_POST."', '".$_POST."')");
?>
<script language="JavaScript">
<!--
| |
by: Brian Basquille |
last post by:
Hello all,
Bit of a change of pace now. As opposed to the typical questions regarding
my Air Hockey game, am also working on a Photo Album which uses an Access
Database to store information about photos. This information is held inside
the database (photoDB.mdb) in a table called 'photos' - information being
recorded in there are photo information (photoID, location, phDate,
category, caption).
I have inputted my own photos (not via...
|
by: brianbasquille |
last post by:
Hello all,
Strange little problem here... am just trying to insert some basic
information into an Access Database using OleDB.
I'm getting a "Syntax error in Insert Into statement" when it tries to
execute the SQL. The strange thing is if i take the exact SQL being
executed from the debugger and insert and execute it using the MS
Access query engine, it works fine!
|
by: ramyap2 |
last post by:
<html>
<body>
<%@ page import="java.sql.*" %>
<%
Connection con=null;
Statement st=null;
ResultSet rs= null;
|
by: hiqu |
last post by:
This issue is driving me nuts and not able to figure out whats wrong.
I've this code in my firefox extension. Firefox always hangs and
reports the script is busy.
if I introduce a break statement in the for(;;) loop below, then
no issue.
Any help would be appreciated!
function getStuff()
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |