hello
again i have a problem....i created some buttons to move through the recordset in the asp page. k problem is that if i click on a button not the next recordset i coming in the textfields .. no its going straight to the listbox menu´again. and so on. only if i click on submit in the form where the list box is the first record of the SQLQuery is shown in the textboxes..
can somebody look at the code ... and say what is wrong or how to solve that. hmmm would be great
caz
<%@LANGUAGE="VBScript"%>
<!-- #INCLUDE VIRTUAL="adovbs.inc" -->
<html>
<head>
<title>main</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#0066FF" text="#000000">
<%If Request("tablename"="" Then%>
<p><b><font size="+2">Please choose a table you want to display:</font></b></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<form name="form" method="post" action="copy_cust_a.asp">
<div align="center">
<select name="tablename" size="4">
<option value="item" >item</option>
<option value="cust" selected>cust</option>
<option value="prod" >prod</option>
<option value="site" >site</option>
</select>
<input type="submit" name="Button" value="Submit">
</div>
</form>
<%Else
DIM tablename
DIM SQLQuery
tablename = Request.Form("tablename"
set myConnection = Server.CreateObject("ADODB.Connection"
myConnection.Open "DSN=ph;UID=sa"
SQLQuery = "select * from " & tablename
if Request("tablename" = "item" Then
SQLQuery ="select item_id,descr,serial from item"
elseif Request("tablename" = "cust" Then
SQLQuery = "select cust_id,descr,address,phone from cust"
elseif Request("tablename" = "prod" Then
SQLQuery = "select prod_id,descr from prod"
elseif Request("tablename" = "site" Then
SQLQuery = "select site_id,descr,address from site"
end if
set rec = Server.CreateObject("ADODB.Recordset"
rec.ActiveConnection = myConnection
rec.CursorType = adOpenKeyset
rec.CursorLocation = adUseClient
rec.LockType = adLockOptimistic
rec.MaxRecords = 10
rec.Open SQLQuery, myConnection
rec.MoveFirst
If Not IsEmpty(Request.Form("MoveAction") Then
strAction = Request.Form("MoveAction"
varPosition = Request.Form("Position"
rec.AbsolutePosition = varPosition
Select Case strAction
Case "MoveNext"
rec.MoveNext
If rec.EOF Then
rec.MoveLast
strMessage = "Can't move beyond the last record."
End If
Case "MovePrev"
rec.MovePrevious
If rec.BOF Then
rec.MoveFirst
strMessage = "Can't move beyond the first record."
End If
Case "MoveLast"
rec.MoveLast
Case "MoveFirst"
rec.MoveFirst
End Select
End If
%>
<form name="form" method="post" action="copy_cust_a.asp">
<% for each field in rec.Fields %>
<table width="50%" border="0" cellspacing="0" cellpadding="0" bordercolor="#000000">
<tr>
<td width="15%"><b><font size="3"><%=field.Name%></font></b></td>
<td width="85%">
<input type="text" name="<%=field.Name%>" VALUE="<%=field.Value%>" size="40">
</td>
</tr>
</table>
<% next %>
<table width="16%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10%">
<input type="Button" name=cmdfirst value="<<<">
</td>
<td width="10%">
<input type="Button" name=cmdPrevious value="<">
</td>
<td width="9%">
<input type="Button" name=cmdNext value=">">
</td>
<td width="71%">
<input type="Button" name=cmdlast value=">>>">
</td>
</tr>
</table>
</form>
<p> </p>
<%end if%>
<Form Method=Post
Action="<%=Request.ServerVariables("SCRIPT_NAME"%>"
Name="form">
<Input Type="Hidden" Size="4" Name="MoveAction" Value="Move">
<Input Type="Hidden" Size="4" Name="Position" Value="<%= rec.AbsolutePosition %>">
</Form>
</body>
</html>
<Script Language = "VBScript">
Sub cmdDown_OnClick
rec.MovePrevious
Document.Form.MoveAction.Value = "MovePrev"
Document.Form.Submit
End Sub
Sub cmdUp_OnClick
rec.MoveNext
Document.form.MoveAction.Value = "MoveNext"
Document.Form.Submit
End Sub
Sub cmdFirst_OnClick
rec.MoveFirst
Document.form.MoveAction.Value = "MoveFirst"
Document.Form.Submit
End Sub
Sub cmdLast_OnClick
rec.MoveLast
Document.form.MoveAction.Value = "MoveLast"
Document.Form.Submit
End Sub
</SCRIPT> [sig][/sig]
again i have a problem....i created some buttons to move through the recordset in the asp page. k problem is that if i click on a button not the next recordset i coming in the textfields .. no its going straight to the listbox menu´again. and so on. only if i click on submit in the form where the list box is the first record of the SQLQuery is shown in the textboxes..
can somebody look at the code ... and say what is wrong or how to solve that. hmmm would be great
caz
<%@LANGUAGE="VBScript"%>
<!-- #INCLUDE VIRTUAL="adovbs.inc" -->
<html>
<head>
<title>main</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#0066FF" text="#000000">
<%If Request("tablename"="" Then%>
<p><b><font size="+2">Please choose a table you want to display:</font></b></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<form name="form" method="post" action="copy_cust_a.asp">
<div align="center">
<select name="tablename" size="4">
<option value="item" >item</option>
<option value="cust" selected>cust</option>
<option value="prod" >prod</option>
<option value="site" >site</option>
</select>
<input type="submit" name="Button" value="Submit">
</div>
</form>
<%Else
DIM tablename
DIM SQLQuery
tablename = Request.Form("tablename"
set myConnection = Server.CreateObject("ADODB.Connection"
myConnection.Open "DSN=ph;UID=sa"
SQLQuery = "select * from " & tablename
if Request("tablename" = "item" Then
SQLQuery ="select item_id,descr,serial from item"
elseif Request("tablename" = "cust" Then
SQLQuery = "select cust_id,descr,address,phone from cust"
elseif Request("tablename" = "prod" Then
SQLQuery = "select prod_id,descr from prod"
elseif Request("tablename" = "site" Then
SQLQuery = "select site_id,descr,address from site"
end if
set rec = Server.CreateObject("ADODB.Recordset"
rec.ActiveConnection = myConnection
rec.CursorType = adOpenKeyset
rec.CursorLocation = adUseClient
rec.LockType = adLockOptimistic
rec.MaxRecords = 10
rec.Open SQLQuery, myConnection
rec.MoveFirst
If Not IsEmpty(Request.Form("MoveAction") Then
strAction = Request.Form("MoveAction"
varPosition = Request.Form("Position"
rec.AbsolutePosition = varPosition
Select Case strAction
Case "MoveNext"
rec.MoveNext
If rec.EOF Then
rec.MoveLast
strMessage = "Can't move beyond the last record."
End If
Case "MovePrev"
rec.MovePrevious
If rec.BOF Then
rec.MoveFirst
strMessage = "Can't move beyond the first record."
End If
Case "MoveLast"
rec.MoveLast
Case "MoveFirst"
rec.MoveFirst
End Select
End If
%>
<form name="form" method="post" action="copy_cust_a.asp">
<% for each field in rec.Fields %>
<table width="50%" border="0" cellspacing="0" cellpadding="0" bordercolor="#000000">
<tr>
<td width="15%"><b><font size="3"><%=field.Name%></font></b></td>
<td width="85%">
<input type="text" name="<%=field.Name%>" VALUE="<%=field.Value%>" size="40">
</td>
</tr>
</table>
<% next %>
<table width="16%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10%">
<input type="Button" name=cmdfirst value="<<<">
</td>
<td width="10%">
<input type="Button" name=cmdPrevious value="<">
</td>
<td width="9%">
<input type="Button" name=cmdNext value=">">
</td>
<td width="71%">
<input type="Button" name=cmdlast value=">>>">
</td>
</tr>
</table>
</form>
<p> </p>
<%end if%>
<Form Method=Post
Action="<%=Request.ServerVariables("SCRIPT_NAME"%>"
Name="form">
<Input Type="Hidden" Size="4" Name="MoveAction" Value="Move">
<Input Type="Hidden" Size="4" Name="Position" Value="<%= rec.AbsolutePosition %>">
</Form>
</body>
</html>
<Script Language = "VBScript">
Sub cmdDown_OnClick
rec.MovePrevious
Document.Form.MoveAction.Value = "MovePrev"
Document.Form.Submit
End Sub
Sub cmdUp_OnClick
rec.MoveNext
Document.form.MoveAction.Value = "MoveNext"
Document.Form.Submit
End Sub
Sub cmdFirst_OnClick
rec.MoveFirst
Document.form.MoveAction.Value = "MoveFirst"
Document.Form.Submit
End Sub
Sub cmdLast_OnClick
rec.MoveLast
Document.form.MoveAction.Value = "MoveLast"
Document.Form.Submit
End Sub
</SCRIPT> [sig][/sig]