页面加载增量 [英] Increment on page load
本文介绍了页面加载增量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在每次加载页面时实现该值增加并显示在标签中
例如
页面加载标签-1显示1
如果再次加载页面,则label-1应显示2,依此类推,每次页面加载时,label-1的值应增加1.
how to implement that on each time page is load the value is increased and displayed in label
e.g
on page load label-1 is displaying 1
and if page is loaded again then label-1 should display 2 and so on on ,each time the page load the value of label-1 should increase by 1 .
推荐答案
在数据库中创建了一个名为hit的表格
然后
页面加载代码
created a table in database named " hit "
then
code on Page Load
<pre lang="vb">If Not IsPostBack Then
Dim co, jo As Integer
cn.ConnectionString = "server=localhost; user id=root; password=; database=**"
cn.Open()
co = 1
s = "select * from hit where id='" & co & "' "
cd = New MySqlCommand(s, cn)
r = cd.ExecuteReader()
r.Read()
jo = CInt(r("count").ToString())
Label5.Text = r("count").ToString()
r.Close()
cn.Close()
Dim c As Integer
Dim s1 As String
cn.ConnectionString = "server=localhost; user id=root; password=; database=**"
cn.Open()
co = 1
c = jo + 1
s1 = "update hit set count='" & c & "' where id='" & co & "'"
cd = New MySqlCommand(s1, cn)
cd.ExecuteNonQuery()
cn.Close()
End If
</pre>
你可以在Application对象或数据存储(数据库,XML文件,文本文件等)中存储值以使其保持不变。
You can store a value in the Application object, or in a data store ( database, XML file, text file, etc ) to make it persist.
这篇关于页面加载增量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文