通过数据库记录的导航代码 [英] Navigation Code through records of a database

查看:69
本文介绍了通过数据库记录的导航代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用此代码创建了一个下一个按钮,以引导我浏览数据库的记录:

I have created a next button with this code to lead me through the records of the database:

Protected Sub btnNext_Click(sender As Object, e As EventArgs) Handles btnNext.Click
       If (inc <> (MaxRows - 1)) Then

           inc = inc + 1

           Next()

       End If
   End Sub


其中


where

MaxRows = dst.Tables("TableName").Rows.Count

Private Sub Next()
txt_kodi.Value = dst.Tables("TableName").Rows(inc).Item(1)
       txt_pershkrimi.Valuedst.Tables("TableName").Rows(inc).Item(1)


当我单击下一个按钮时,它将始终保存我给变量inc赋予的第一个值.
所以它总是将我引向第二行,仅此而已.我不能移至第三个或第四个.


When I click the next button it always save the first value I give to variable inc.
so it always leads me to the second row and that''s all. I can''t move to the third or the fourth.

推荐答案

如果这是基于Web的,那么是的,那是我所期望的-您的变量不是在显示页面时保留,但每次在用户引起回发时发生页面加载事件时,都会重新创建它们.

如果要保留一个值并增加它,则需要将其保留在页面上(作为隐藏控件的可见部分),或者将其保存在Session中,并在每次希望移至下一条记录时进行检索.

如果这不是基于Web的,则需要提供更多有关其他因素影响inc
If this is Web based, then yes, that is what I would expect - your variables are not preserved while the page is displayed, they are re-created each time as a Page Load event occurs when the user causes a post-back.

If you want to keep a value and increment it, then you either need to keep it on the page (as a visible of hidden control) or save it in the Session and retrieve it each time you wish to move on to the next record.

If this isn''t web based, then you need to provide more information as to what else affects the value of inc


这篇关于通过数据库记录的导航代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆