Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Recordset problem

New Here ,
Oct 06, 2006 Oct 06, 2006
Hi: I have a edit/update record form in asp. Everytime I attempt to access a record from the admin panel, I get redirected to the first record in the DB. On hover, the browser shows the correct record ID to access, but on click it displays the first record. Can someone look at this code and see if you spot a error - or a code modification that will correct this problem. Thanks in advance ...

<%
' *** Update Record: set variables

If (CStr(Request("MM_update")) = "form1" And CStr(Request("MM_recordId")) <> "") Then

MM_editConnection = MM_db1_STRING
MM_editTable = "name"
MM_editColumn = "ID"
MM_recordId = "" + Request.Form("MM_recordId") + ""
MM_editRedirectUrl = "db_confirm.asp"

' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")

' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next

' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If

End If
%>

<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_db1_STRING
Recordset1.Source = "SELECT ID FROM name"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<%
Dim rs_edit
Dim rs_edit_numRows

Set rs_edit = Server.CreateObject("ADODB.Recordset")
rs_edit.ActiveConnection = MM_db1_STRING
rs_edit.Source = "SELECT * FROM name"
rs_edit.CursorType = 0
rs_edit.CursorLocation = 2
rs_edit.LockType = 1
rs_edit.Open()

rs_edit_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = 25
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<%
' *** Recordset Stats, Move To Record, and Go To Record: declare stats variables

Dim Recordset1_total
Dim Recordset1_first
Dim Recordset1_last

' set the record count
Recordset1_total = Recordset1.RecordCount

' set the number of rows displayed on this page
If (Recordset1_numRows < 0) Then
Recordset1_numRows = Recordset1_total
Elseif (Recordset1_numRows = 0) Then
Recordset1_numRows = 1
End If

' set the first and last displayed record
Recordset1_first = 1
Recordset1_last = Recordset1_first + Recordset1_numRows - 1

' if we have the correct record count, check the other stats
If (Recordset1_total <> -1) Then
If (Recordset1_first > Recordset1_total) Then
Recordset1_first = Recordset1_total
End If
If (Recordset1_last > Recordset1_total) Then
Recordset1_last = Recordset1_total
End If
If (Recordset1_numRows > Recordset1_total) Then
Recordset1_numRows = Recordset1_total
End If
End If
%>
TOPICS
Server side applications
263
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 09, 2006 Oct 09, 2006
LATEST
Your recordset does not have any selection criteria on it so it will always
return the same data, and as such will always display the first record.

--
Paul Whitham
Certified Dreamweaver MX2004 Professional
Adobe Community Expert - Dreamweaver

Valleybiz Internet Design
www.valleybiz.net

"macrostrubel" <webforumsuser@macromedia.com> wrote in message
news:eg5o79$pik$1@forums.macromedia.com...
> Hi: I have a edit/update record form in asp. Everytime I attempt to access
> a
> record from the admin panel, I get redirected to the first record in the
> DB. On
> hover, the browser shows the correct record ID to access, but on click it
> displays the first record. Can someone look at this code and see if you
> spot a
> error - or a code modification that will correct this problem. Thanks in
> advance ...
>
> <%
> ' *** Update Record: set variables
>
> If (CStr(Request("MM_update")) = "form1" And CStr(Request("MM_recordId"))
> <>
> "") Then
>
> MM_editConnection = MM_db1_STRING
> MM_editTable = "name"
> MM_editColumn = "ID"
> MM_recordId = "" + Request.Form("MM_recordId") + ""
> MM_editRedirectUrl = "db_confirm.asp"
>
> ' create the MM_fields and MM_columns arrays
> MM_fields = Split(MM_fieldsStr, "|")
> MM_columns = Split(MM_columnsStr, "|")
>
> ' set the form values
> For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
> MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
> Next
>
> ' append the query string to the redirect URL
> If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
> If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And
> Request.QueryString <> "") Then
> MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
> Else
> MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
> End If
> End If
>
> End If
> %>
>
> <%
> Dim Recordset1
> Dim Recordset1_numRows
>
> Set Recordset1 = Server.CreateObject("ADODB.Recordset")
> Recordset1.ActiveConnection = MM_db1_STRING
> Recordset1.Source = "SELECT ID FROM name"
> Recordset1.CursorType = 0
> Recordset1.CursorLocation = 2
> Recordset1.LockType = 1
> Recordset1.Open()
>
> Recordset1_numRows = 0
> %>
> <%
> Dim rs_edit
> Dim rs_edit_numRows
>
> Set rs_edit = Server.CreateObject("ADODB.Recordset")
> rs_edit.ActiveConnection = MM_db1_STRING
> rs_edit.Source = "SELECT * FROM name"
> rs_edit.CursorType = 0
> rs_edit.CursorLocation = 2
> rs_edit.LockType = 1
> rs_edit.Open()
>
> rs_edit_numRows = 0
> %>
> <%
> Dim Repeat1__numRows
> Dim Repeat1__index
>
> Repeat1__numRows = 25
> Repeat1__index = 0
> Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
> %>
> <%
> ' *** Recordset Stats, Move To Record, and Go To Record: declare stats
> variables
>
> Dim Recordset1_total
> Dim Recordset1_first
> Dim Recordset1_last
>
> ' set the record count
> Recordset1_total = Recordset1.RecordCount
>
> ' set the number of rows displayed on this page
> If (Recordset1_numRows < 0) Then
> Recordset1_numRows = Recordset1_total
> Elseif (Recordset1_numRows = 0) Then
> Recordset1_numRows = 1
> End If
>
> ' set the first and last displayed record
> Recordset1_first = 1
> Recordset1_last = Recordset1_first + Recordset1_numRows - 1
>
> ' if we have the correct record count, check the other stats
> If (Recordset1_total <> -1) Then
> If (Recordset1_first > Recordset1_total) Then
> Recordset1_first = Recordset1_total
> End If
> If (Recordset1_last > Recordset1_total) Then
> Recordset1_last = Recordset1_total
> End If
> If (Recordset1_numRows > Recordset1_total) Then
> Recordset1_numRows = Recordset1_total
> End If
> End If
> %>
>
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines