Gaby said:
OK!!! I think we are getting somewhere. It was a typo I overlooked.
<%
dim cn, ar(4)
ar(0)="222334444"
ar(1)="Norton"
ar(2)="581371"
ar(3)="3"
ar(4)="3"
Again, are these numbers going into Text fields? If not, then you need to
remove the quotes:
ar(4) = 3
set cn=createobject("adodb.connection")
cn.open "provider=microsoft.jet.oledb.4.0;" & _
"data source=" & server.mappath("hgb_experiment.mdb")
cn.qInsertRecord ar(0),ar(1),ar(2),ar(3),ar(4)
cn.close:set cn=nothing
%>
The information was passed into the table!!
Whats the next step?
Im getting excited. Hopefully, I can get it the form working.
OK, now you understand (I hope) the mechanism for passing the data to the
parameters in your saved query. The idea is to pass them in the same order
in which they appear in your saved query, which you can now confirm has been
accomplished.
Let's move on to incorporating it into your existing form ... but let's do
it in small steps. I assume you have a form where the user enters and
submits the data. So change the action property of the form tag to make it
submit to this test page. Then, in this test page, change the hard-coded
values to references to the form variables coming from the submission.
ar(0) = Request.Form("name of variable")
Run your form, enter some test data, submit it, and verify that it gets
added into your database. I would suggest adding this code to the test page,
right after the line that executes the saved query:
dim sql, cmd, arParms, html
sql="Select Roster, Instructor, [Password]," & _
"1_AbletoGiveOrders, 2_Appreciative " & _
"From Research Where Roster = ?"
arParms=Array(ar(0))
set cmd=createobject("adodb.command")
cmd.commandtype=1 'adCmdText
cmd.commandtext=sql
set cmd.activeconnection=cn
set rs=cmd.execute(,arParms)
if rs.eof then
response.write "No record was inserted"
else
response.write "<table border=""1"" "
response.write "style=""border-collapse:collapse;""><tr>"
response.write "<th>Roster</th>"
response.write "<th>Instructor</th>"
response.write "<th>Password</th>"
response.write "<th>1_AbletoGiveOrders</th>"
response.write "<th>2_Appreciative</th></tr><tr><td>"
html=rs.getstring(2,,"</td><td>","</td></tr><tr><td>")
html=left(html,len(html) - 8)
response.write html
response.write "</table>"
end if
rs.close:set rs=nothing
Once you have that accomplished, the next step will be to add some code to
validate that the user enters data that is correct. Users sometime make
mistakes an do things like entering alpha characters when you are expecting
numbers, or entering nothing at all. And some users will maliciously enter
data designed to either damage your database or break into it. See
http://mvp.unixwiz.net/techtips/sql-injection.html
http://www.sqlsecurity.com/DesktopDefault.aspx?tabid=23
You need to deal with these situations before you even create your
connection object ... but, one step at a time.