| | |
Unable to insert form data into a database
Please support our ASP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Hey all,
Heres the code of an ASP I'm working on...
------------------------------------begin ASP-------------------------------------
<%@ Language=VBScript%>
<%
artist=Request("artist")
album=Request("album")
Set con1 = server.CreateObject ("ADODB.Connection")
Set rs1 = server.CreateObject ("ADODB.Recordset")
con1.Provider="Microsoft.Jet.OLEDB.4.0"
con1.Open (server.MapPath ("\databasecore\mediaguide.mdb"))
sql = "UPDATE artistinfo SET UserAlbumReview='"&TRIM(Request.Form("AlbumReview"))&"' where artist ='"&artist&"' and album =
'"&album&"'"
rs1.Open sql,con1
%>
<html>
<head>
<title>Add Album Review</title>
<meta name="Microsoft Theme" content="profile 111, default">
</head>
<body>
<form name=review method="POST" action="review.asp?done=1">
<p align="center">
<textarea rows="8" name="AlbumReview" cols="31"></textarea></p>
<p align="center">
<input type="submit" value="Submit"><input type="reset" value="Reset"></p>
</form>
</body></html>
--------------------------------------------end ASP---------------------------------
What I want is that when a user enters text in the textarea, the same should be inserted in the field named UserAlbumReview
in the database. However, this isnt happening. Nothing is inserted in the database. However, if I bubstitue a phrase in the
SQL query instead of the Request.Form statement, the string is inserted properly.ie, if I change the SQL query to
sql = "UPDATE artistinfo SET UserAlbumReview='Test Review' where artist ='"&artist&"' and album = '"&album&"'"
then the phrase "Test Review" is inserted in the database. The values for artist and album are passed as parameters. Can any of you guys please help me? Thanks in advance.
Heres the code of an ASP I'm working on...
------------------------------------begin ASP-------------------------------------
<%@ Language=VBScript%>
<%
artist=Request("artist")
album=Request("album")
Set con1 = server.CreateObject ("ADODB.Connection")
Set rs1 = server.CreateObject ("ADODB.Recordset")
con1.Provider="Microsoft.Jet.OLEDB.4.0"
con1.Open (server.MapPath ("\databasecore\mediaguide.mdb"))
sql = "UPDATE artistinfo SET UserAlbumReview='"&TRIM(Request.Form("AlbumReview"))&"' where artist ='"&artist&"' and album =
'"&album&"'"
rs1.Open sql,con1
%>
<html>
<head>
<title>Add Album Review</title>
<meta name="Microsoft Theme" content="profile 111, default">
</head>
<body>
<form name=review method="POST" action="review.asp?done=1">
<p align="center">
<textarea rows="8" name="AlbumReview" cols="31"></textarea></p>
<p align="center">
<input type="submit" value="Submit"><input type="reset" value="Reset"></p>
</form>
</body></html>
--------------------------------------------end ASP---------------------------------
What I want is that when a user enters text in the textarea, the same should be inserted in the field named UserAlbumReview
in the database. However, this isnt happening. Nothing is inserted in the database. However, if I bubstitue a phrase in the
SQL query instead of the Request.Form statement, the string is inserted properly.ie, if I change the SQL query to
sql = "UPDATE artistinfo SET UserAlbumReview='Test Review' where artist ='"&artist&"' and album = '"&album&"'"
then the phrase "Test Review" is inserted in the database. The values for artist and album are passed as parameters. Can any of you guys please help me? Thanks in advance.
For starters you need troubleshoot your variables...
When my sql is not working properly I like to write it out to screen before it executes to see what are the actual values being passed.
Response.Write(sql) and comment out the
' rs1.Open sql,con1
Also I'm not sure Request("myTextbox") is a proper way of retriving form variables in ASP. I always use Request.Form() or Request.QueryString()
When my sql is not working properly I like to write it out to screen before it executes to see what are the actual values being passed.
Response.Write(sql) and comment out the
' rs1.Open sql,con1
Also I'm not sure Request("myTextbox") is a proper way of retriving form variables in ASP. I always use Request.Form() or Request.QueryString()
![]() |
Similar Threads
- load data from access database into form (VB.NET)
- insert data from one form into two diffent database table (JSP)
- copy data from excel to vb database (Visual Basic 4 / 5 / 6)
- Inserting Data into Access Database (Java)
- Unable to insert data into database. (MySQL)
- SQL Query inserts junk data as well (ASP)
- Posting form data to an Oracle database (JavaScript / DHTML / AJAX)
Other Threads in the ASP Forum
- Previous Thread: Asp + Jet
- Next Thread: Help with export to dbf
| Thread Tools | Search this Thread |
archive asp asp.net aspandmssqlserver2005 aspandmssqlserver2005connection aspconnection connection database databaseconnection dreamweaver excel fso iis msmsql mssql2005 mssqlserver2005 mssqlserver2005andasp mssqlserverandasp opentextfile record searchbox selectoption single specfic sqlserver sqlserverconnection windows7






