Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Access DB with ASP table

Status
Not open for further replies.

malaygal

IS-IT--Management
Feb 22, 2006
192
US
I have a table that I want to use to update an Access database.
One of the table field is an input with date/time value.
Before I update the db, I would want to evaluate this input fied if it is greater than Now().

How can I pass these table (with rows and columns) to an execute page that will evaluate the input and update the access db.

Any help will be greatly appreciated.
 
Or maybe I can do this using server-side script. Although, I still do not know how:

This is my asp page:

Set rs = Server.CreateObject("ADODB.Recordset")
strsql = "SELECT * from tblLock where version = '" & version & "' and state = '" & state & "' "
rs.Open strsql, objConn
' loop through the recordset..
if rs.eof then
response.write "<b>No record</b>"
else

%>
<table width="75%" border = 1>
<TR>
<TD><B><FONT FACE="Arial" SIZE=2>STATE</B></FONT></TD>
<TD><b><FONT FACE="Arial" SIZE=2><P>VERSION</b></FONT></TD>
<TD><b><FONT FACE="Arial" SIZE=2><P>LOCK ON</b></FONT></TD>
</TR>
<%
rs.movefirst
Do Until rs.EOF
%>
<TR>
<TD><FONT FACE="Arial" SIZE=1><%=rs("state")%></FONT></TD>
<TD><FONT FACE="Arial" SIZE=1><%=rs("version")%></FONT></TD>
<TD><FONT FACE="Arial" SIZE=1 color="green"><input type="text" size="25" value ="<%=rs("LockDate")%>"></input>
</TR>
<%

rs.MoveNext
Loop
' finish the version listbox...
end if
rs.close
End if
%>
</table>
<table>
<tr><td>&nbsp;</td>
<tr><td align=left><input type = image src="bsubmit.gif" onClick="Run_OnClick();return false"></td></tr>

I would have used Run_OnClick() - Javascript to do the evaluation and update the DB
 
Make it an HTML <form> that submits to dates to the server.
 
I have this asp page with data coming from an Access Database

<%@ language = "VBScript" %>
<%Response.Buffer=true%>
<%Response.Clear%>
<head>
<%
Dim version, schedule
version = trim(Request.Form("version"))
schedule=trim(Request.Form("schedule"))
%>

<script language="javascript">

function optCountry()
{
var fDiv=document.getElementById("dCountry");
var fDivLock=document.getElementById("dSchedule");
var fDivStyle=fDiv.style;
var fDivStyleLock=fDivLock.style;
fDivStyle.display="block";
fDivStyleLock.display="none";
}
</script>
<body bgcolor="white" text="black" >
<form name="frmLock" action=versionform.asp method=post>
<center>
<%
Dim objConnection,Comm, rs, strsql,sConnect
adOpenForwardOnly = 0
adLockReadOnly = 1
adCmdText = 1
sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Upload.mdb"
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open sConnect
Set rs = Server.CreateObject("ADODB.Recordset")
strsql = "SELECT * from tblLock where version = '" & version & "' and schedule = '" & schedule & "' "
rs.Open strsql, objConn
if rs.eof then
else
%>
<table width="75%" border = 1>
<TR>
<TD><B><FONT FACE="Arial" SIZE=2>VERSION</B></FONT></TD>
<TD><B><FONT FACE="Arial" SIZE=2>COUNTRY</B></FONT></TD>
<TD><b><FONT FACE="Arial" SIZE=2><P>SCHEDULE</b></FONT></TD>
<TD><b><FONT FACE="Arial" SIZE=2><P>LOCK ON</FONT></b></TD>
</TR>
<%
rs.movefirst
Do Until rs.EOF
%>
<TR>
<TD><FONT FACE="Arial" SIZE=1><%=rs("version")%></FONT></TD>
<TD><FONT FACE="Arial" SIZE=1><%=rs("country")%></FONT></TD>
<TD><FONT FACE="Arial" SIZE=1><%=rs("schedule")%></FONT></TD>
<TD><FONT FACE="Arial" SIZE=1 color="green"><input id="<%=rs("schedule")%><%=rs("country")%>" type="text" size="25" value ="<%=rs("LockDate")%>">
</TR>
<%
rs.MoveNext
Loop
end if
rs.close
%>
</table>

<input type = image src="/bsubmit.gif" onClick=" ">

</form>
</BODY>
</HTML>

Page display data as : [denotes input]

Country Version Schedule LockDate

HONG KONG Budget A1111 [02/28/07 11:30 PM]
China Budget A1111 [03/01/07 02:30 AM]
India Forecast A2222 [ ]

[SUBMIT]

I need this <input type = image src="/bsubmit.gif" onClick=" "> to go to another page where I can validate the input (which is in a date format) and update the Access database.
I don't think I have any prolbem if I only have one row of data, but I do not know how to pass multiple rows to that page and if I am able to, how to loop to the incoming records to validate input field and update the Access database.

 
I hate to sound pushy, but I am desperately in need of help on this. I have this project due in two days and I am stuck with this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top