Hello
I think I have managed to learn how to display the records my MSAccess 2000 database contains.
And I think I have managed to understand how SQL inserts records into a database (partly through the kind assistance of one or two folks here).
What I would now like to do, is to be able to show the visitor a Web page which holds all the records, including those newly inserted records.
In other words, the visitor will see a Web page with database records. There will be 2 insert boxes (first namne and last name) and a submit button for him to add his own records. Then, having clicked submit, I hope to be able to show him all the records in the DB, plus the records he has just added.
The code I have so far for 'display records' is:
(test.asp)
<%@language=vbscript%>
<%
Option Explicit
Dim ConnectionString
Dim connObj
Dim sql
Dim oRS
ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("\stevehigham\db\testDB.mdb"
& ";" & _
"Persist Security Info=False"
Set ConnObj = Server.CreateObject("ADODB.Connection"
connObj.Open ConnectionString
sql = "select * from Table1"
sql = "SELECT girlSurname, girlFirst FROM Table1 ORDER BY girlSurname"
Set oRS = connObj.Execute(sql)
Do While Not oRS.EOF
Response.Write(oRS("girlFirst"
& " - " & oRS("girlSurname"
& "<br>"
oRS.MoveNext
Loop
oRS.Close
connObj.Close
Set oRS = Nothing
Set connObj = Nothing
%>
and the code I have for INSERT INTO is:
<%
Option Explicit
Dim ConnectionString, connObj, sql, frmFirst, frmSur
frmFirst = Request.Form("first"
frmSur = Request.Form("sur"
ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("\stevehigham\db\testDB.mdb"
& ";" & _
"Persist Security Info=False"
Set ConnObj = Server.CreateObject("ADODB.Connection"
connObj.Open ConnectionString
sql = "select * from Table1"
sql = "INSERT INTO Table1 (girlFirst, girlSurname) VALUES ('" & frmFirst & "','" & frmSur & "')"
connObj.Execute(sql)
connObj.Close
Set connObj = Nothing
%>
And finally the form I have is:
<HTML>
<HEAD>
<TITLE>
</TITLE>
<BODY>
<form name="form1" method="post" action="page2.asp">
<input type="text" name="first">
<input type="text" name="sur">
<input type="text" value="Clear">
<input type="submit" name="Submit" value="Add">
</form>
</BODY>
</HTML>
Moreover, is it possible to achieve what I am aiming for, without creating more asp files (I already have 3).
Many thanks for any suggestions on how to do this.
LaPluma
I think I have managed to learn how to display the records my MSAccess 2000 database contains.
And I think I have managed to understand how SQL inserts records into a database (partly through the kind assistance of one or two folks here).
What I would now like to do, is to be able to show the visitor a Web page which holds all the records, including those newly inserted records.
In other words, the visitor will see a Web page with database records. There will be 2 insert boxes (first namne and last name) and a submit button for him to add his own records. Then, having clicked submit, I hope to be able to show him all the records in the DB, plus the records he has just added.
The code I have so far for 'display records' is:
(test.asp)
<%@language=vbscript%>
<%
Option Explicit
Dim ConnectionString
Dim connObj
Dim sql
Dim oRS
ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("\stevehigham\db\testDB.mdb"
"Persist Security Info=False"
Set ConnObj = Server.CreateObject("ADODB.Connection"
connObj.Open ConnectionString
sql = "select * from Table1"
sql = "SELECT girlSurname, girlFirst FROM Table1 ORDER BY girlSurname"
Set oRS = connObj.Execute(sql)
Do While Not oRS.EOF
Response.Write(oRS("girlFirst"
oRS.MoveNext
Loop
oRS.Close
connObj.Close
Set oRS = Nothing
Set connObj = Nothing
%>
and the code I have for INSERT INTO is:
<%
Option Explicit
Dim ConnectionString, connObj, sql, frmFirst, frmSur
frmFirst = Request.Form("first"
frmSur = Request.Form("sur"
ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("\stevehigham\db\testDB.mdb"
"Persist Security Info=False"
Set ConnObj = Server.CreateObject("ADODB.Connection"
connObj.Open ConnectionString
sql = "select * from Table1"
sql = "INSERT INTO Table1 (girlFirst, girlSurname) VALUES ('" & frmFirst & "','" & frmSur & "')"
connObj.Execute(sql)
connObj.Close
Set connObj = Nothing
%>
And finally the form I have is:
<HTML>
<HEAD>
<TITLE>
</TITLE>
<BODY>
<form name="form1" method="post" action="page2.asp">
<input type="text" name="first">
<input type="text" name="sur">
<input type="text" value="Clear">
<input type="submit" name="Submit" value="Add">
</form>
</BODY>
</HTML>
Moreover, is it possible to achieve what I am aiming for, without creating more asp files (I already have 3).
Many thanks for any suggestions on how to do this.
LaPluma