<!-- #include file="ADOVBS.INC" -->
<%
Dim namn
Dim text
Dim datum
Dim tid
Dim ip
namn = Request.Form("name")
text = Request.Form("text")
datum = (FormatDateTime(Now(),2))
tid = (FormatDateTime(Now(),4))
ip = Request.ServerVariables("REMOTE_ADDR")
set conn = Server.CreateObject("ADODB.Connection")
conn.open "Driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("database01.mdb")
sql = "INSERT INTO Klotter (Name,Text,Datum,Tid,IP)"
sql = sql & " VALUES(" & namn & "," & text & ",'" & datum & "','" & tid & "','" & ip & "')"
conn.Execute(sql)
conn.close
Response.Redirect "default.asp?page=007"
%>
Denna sidan tar emot värden från "klotter.asp" där man kan skriva in namn och "klotter".. sedan, när denna sidan körs får jag fram detta felmeddelandet:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
/klotter_add.asp, line 21
och den raden är ju den med "conn.execute(sql)
jag o en polare har slitit vårat hår nu.. vad är det som är fel..?? har testat med fyrkanter och fnuttar o allt.. men det ger sig inte..
------------------
"Every morning in Africa, a gazelle wakes up, it knows it must outrun the fastest lion, or else it will be eaten. Every morning in Africa a lion wakes up, it knows it must outrun the slowest gazelle, or else it will starve to death. It doesn't matter if you're a lion or a gazelle, when the sun rises, you better be running.."
<!-- #include file="ADOVBS.INC" -->
<%
Dim callID
Dim body
Dim dag
Dim tpunkt
Dim ip
callID = Request.Form("namn")
body = Request.Form("body")
dag = (FormatDateTime(Now(),2))
tpunkt = (FormatDateTime(Now(),4))
ip = Request.ServerVariables("REMOTE_ADDR")
set conn = Server.CreateObject("ADODB.Connection")
conn.open "Driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("database01.mdb")
sql = "INSERT INTO Klotter (CallID,Body,Dag,tpunkt,IP)"
sql = sql & " VALUES(" & callID & "," & body & ",'" & dag & "','" & tpunkt & "','" & ip & "')"
conn.Execute(sql)
conn.close
Response.Redirect "default.asp?page=007"
%>
Denna kod genererar nu följande felmeddelande, har fått upp det på andra sidor, men med min ringa vetskap vet jag inte hur jag fick bort det. :)
Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2.
/klotter_add.asp, line 21
Tack @nders! :P
------------------
"Every morning in Africa, a gazelle wakes up, it knows it must outrun the fastest lion, or else it will be eaten. Every morning in Africa a lion wakes up, it knows it must outrun the slowest gazelle, or else it will starve to death. It doesn't matter if you're a lion or a gazelle, when the sun rises, you better be running.."
Text-värden anges inom '
Datetime-värden anges inom #
Numeriska värden har inga avgränsare
okej.. men min "dag", "tpunkt" och "ip" innehåller siffror och punkter m.m. "tpunkt" innehåller ex. "22:15"
och "ip".. tja.. "127.0.0.1"
ska man skriva dom som '# & tpunkt & #'?
------------------
"Every morning in Africa, a gazelle wakes up, it knows it must outrun the fastest lion, or else it will be eaten. Every morning in Africa a lion wakes up, it knows it must outrun the slowest gazelle, or else it will starve to death. It doesn't matter if you're a lion or a gazelle, when the sun rises, you better be running.."