Ask a Question related to ASP Database, Design and Development.
-
vasanth kumar #1
Adding rows to database table thro' ASP
Hi,
I want to add a row to library table. Table has total 7 fields. But I want to create the new row with 5 field data. When I run the following query in MS Access
strQ = "INSERT into library (index,title,author,itemtype,createdate) VALUES ('B-096','Hihihihihi','hello','Book','07/18/04')"
It successfully adds the row. But same thing I am trying with the following ASP code. It gives error, saying syntax error in INSERT into statement.
Can anybody suggest me, what is wrong in my code below. Any help is appreciated.
Thanks in advance,
Vasanth
-----------------------------
<%
option explicit
Response.ExpiresAbsolute = "January 1, 2003"
Dim path, mdbFilePath, sPos, objConnect, objRst, strQ, x
for each x in Request.Form
execute x & "="""&Request(x)&""""
next
path = Request.ServerVariables("PATH_TRANSLATED")
sPos = InStr(path, "library\newupdate.asp")
if sPos = 0 then
sPos = InStr(path, "library/newupdate.asp")
end if
mdbFilePath = Left(path, sPos-1) & "library.mdb"
Set objConnect = Server.CreateObject("ADODB.Connection")
objConnect.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mdbFilePath & ";"
Set objRst = Server.CreateObject("ADODB.Recordset")
Set objRst.ActiveConnection = objConnect
'strQ = "INSERT into library (index,title,author,itemtype,createdate) VALUES ('"&session("index")&"','"&title&"','"&author&"',' "&session("itemtype")&"','"&date&"')"
strQ = "INSERT into library (index,title,author,itemtype,createdate) VALUES ('B-096','Hihihihihi','hello','Book','07/18/04')"
objRst.Open strQ
Set objRst = nothing
objConnect.Close
Set objConnect = nothing
%>
<html>
<head>
<title>
</title>
</head>
<body>
Library Item, <%=session("index")%> has been created on <%=date%>.
</body>
</html>
vasanth kumar Guest
-
Adding rows to database table thro ASP
Hi, I want to add a row to library table. Table has total 7 fields. But I want to create the new row with 5 field data. When I run the following... -
#25473 [Opn->Bgs]: Updating single row in table causing all rows in table to be updated.
ID: 25473 Updated by: sniper@php.net Reported By: jim at bluedojo dot com -Status: Open +Status: ... -
#25473 [Fbk->Opn]: Updating single row in table causing all rows in table to be updated.
ID: 25473 User updated by: jim at bluedojo dot com Reported By: jim at bluedojo dot com -Status: Feedback +Status: ... -
#25473 [Opn->Fbk]: Updating single row in table causing all rows in table to be updated.
ID: 25473 Updated by: sniper@php.net Reported By: jim at bluedojo dot com -Status: Open +Status: ... -
#25473 [NEW]: Updating single row in table causing all rows in table to be updated.
From: jim at bluedojo dot com Operating system: WinXP PHP version: 4.3.3 PHP Bug Type: MySQL related Bug description: ...



Reply With Quote

