显示记录 [英] Show records

查看:95
本文介绍了显示记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




Als初学者,我正在寻找一种方式来显示记录

我的代码是

私人sub Connection(

Dim odbconn_Pro As OleDbConnectio

Dim odbcomm_Pro作为OleDbComman

Dim odbdare_Pro作为OleDbDataReade

Dim DataFile as Strin

DataFile =" H:\ Production \ Prod.mdb

odbconn_Pro = New OleDbConnection(" Provider = Microsoft.Jet.OLEDB.4.0;"

&" DATA SOURCE ="& DataFile

odbcomm_Pro = New OleDbComman

odbcomm_Pro.CommandText =" SELECT * FROM Collection ORDER BY bt_code

odbcomm_Pro.Connection = odbconn_Pr

odbcomm_Pro.Connection.Open(

odbdare_Pro = odbcomm_Pro.ExecuteReade

如果odbdare_Pro.HasRows

ShowDetail(

结束我

结束Su


Private Sub ShowDetail(

虽然odbdare_Pro.Read(

lblCode.Text = odbdare_Pro(" bt_code)

lblName.Text = odbdare_Pro(" bt_Name"

....

....

End Whil

结束Su


当这个项目运行时。它只显示最后一条记录。我知道为什么,因为我使用:虽然odbdare_Pro.Read()

所以程序读取所有记录并显示最后一个

我想要的是程序刚刚显示第一个记录同时我有4个工具栏按钮:First Record,Previous,Next和最后导航显示哪条记录

显示第一条记录后,用户可以点击4个按钮中的一个。

如果是第一条记录。单击按钮,将显示第一条记录

如果是上一页单击按钮,将显示所显示记录的先前记录

如果下一步按下单击按钮,将显示所显示记录的下一条记录

如果最后按钮单击按钮,将显示最后一条记录


我该怎么做?请有人帮帮我


提前致谢


Joachim

解决方案

约阿希姆,

如果您使用datareader读取而不是将其存储在对象中,则只有内存中的最新信息。
/>

然而,只需使用dataadapter,数据集(所有内容都在

中),使用* data *绑定和bindinmanager就可以完成所有工作希望

以一种非常简单的方式,在msdn上查找你的自我。


Cor


Cor

你能给我一个样品,请


谢谢。


< blockquote>嗨Joachim,


我在这条消息中这样做,所以注意拼写错误

私人子连接()
Dim odbconn_Pro作为OleDbConnection
Dim odbcomm_Pro作为OleDbCommand
Dim odbdare_Pro作为OleDbDataReader Dim DataFile as String
DataFile =" H:\ Production\Prod.mdb"
odbconn_Pro = New
OleDbConnection(" Provider = Microsoft.Jet.OLEDB.4.0 ; " _& DATA SOURCE = &安培; DataFile)
odbcomm_Pro =新的OleDbCommand
odbcomm_Pro.CommandText =" SELECT * FROM Collection ORDER BY
bt_code" odbcomm_Pro.Connection = odbconn_Pro
odbcomm_Pro.Connection.Open()



dim ds as new dataset

dim da as new dataadaper(odbcomm_Pro)< br $>
da.fill(ds)

cma = CType(BindingContext(ds.Tables(0)),CurrencyManager)

textbox1.DataBindings.Add (New Binding(" Text",ds.Tables(0),

" YourFieldName"))


设置

cma.position = 0你在第一个postision上设置位置,第一个

行将会显示


我希望这有点清除它否则回复


Cor


Hi,

Als a beginner, I am looking for a way to show records
My code is
Private sub Connection(
Dim odbconn_Pro As OleDbConnectio
Dim odbcomm_Pro As OleDbComman
Dim odbdare_Pro As OleDbDataReade
Dim DataFile as Strin
DataFile = "H:\Production\Prod.mdb
odbconn_Pro = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; "
& "DATA SOURCE=" & DataFile
odbcomm_Pro = New OleDbComman
odbcomm_Pro.CommandText = "SELECT * FROM Collection ORDER BY bt_code
odbcomm_Pro.Connection = odbconn_Pr
odbcomm_Pro.Connection.Open(
odbdare_Pro = odbcomm_Pro.ExecuteReade
If odbdare_Pro.HasRows The
ShowDetail(
End I
End Su

Private Sub ShowDetail(
While odbdare_Pro.Read(
lblCode.Text = odbdare_Pro("bt_code"
lblName.Text = odbdare_Pro("bt_Name"
....
....
End Whil
End Su

When this proram run. It show only the last record. I know why, because I use : While odbdare_Pro.Read()
So the program read all the records and shows the last one
What I want is the program just shows the first record

Meanwhile I have 4 toolbar Buttons : "First Record", "Previous", "Next" and "Last" to navigate which record to show
After the first record is showed, the user can click one of the 4 buttons.
If the "First Record" button is clicked, the first record will be showed
If the "Previous" button is clicked, the previous record of the shown record will be showed
If the "Next" button is clicked, the next record of the shown record will be showed
If the "Last" button is clicked, the last record will be showed

How can I do like this ? Please somebody help me

Thanks in advance

Joachim

解决方案

Hi Joachim,

If you read using the datareader and not store that in an object you have
only the latest information in memory.

However just by using the dataadapter, the dataset (with all what is in
this), using the *data*binding and the bindinmanager you can do all you want
in a very easy way, have a look for your self to it in/on msdn.

Cor


Cor
Can you give me a sample, please

Thanks.


Hi Joachim,

I do this in this message so watch for typos

Private sub Connection()
Dim odbconn_Pro As OleDbConnection
Dim odbcomm_Pro As OleDbCommand
Dim odbdare_Pro As OleDbDataReader
Dim DataFile as String
DataFile = "H:\Production\Prod.mdb"
odbconn_Pro = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " _ & "DATA SOURCE=" & DataFile)
odbcomm_Pro = New OleDbCommand
odbcomm_Pro.CommandText = "SELECT * FROM Collection ORDER BY bt_code" odbcomm_Pro.Connection = odbconn_Pro
odbcomm_Pro.Connection.Open()


dim ds as new dataset
dim da as new dataadaper(odbcomm_Pro)
da.fill(ds)
cma = CType(BindingContext(ds.Tables(0)), CurrencyManager)
textbox1.DataBindings.Add(New Binding("Text", ds.Tables(0),
"YourFieldName"))

With seting the
cma.position = 0 you set the position on the first postision and the first
row will be displayed

I hope this clears it a little bit otherwise reply

Cor


这篇关于显示记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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