V
vasanth kumar
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>
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>