当前位置: 编程技术>.net/c#/asp.net
数据绑定到两个不同的datagrid控件(vb.net)
来源: 互联网 发布时间:2014-08-30
本文导语: 在vb.net中实现绑定数据到两个不同的datagrid控件中。 代码: 代码示例: sub page_load(byval sender as object, byval e as eventargs) dim dbconn as oledbconnection dim dbcommand as oledbdataadapter dim dspagedata as new dataset dbconn...
在vb.net中实现绑定数据到两个不同的datagrid控件中。
代码:
代码示例:
sub page_load(byval sender as object, byval e as eventargs)
dim dbconn as oledbconnection
dim dbcommand as oledbdataadapter
dim dspagedata as new dataset
dbconn = new oledbconnection( _
"provider=microsoft.jet.oledb.4.0;" _
& "data source=" _
& server.mappath("employeedatabase.mdb;"))
dbcommand = new oledbdataadapter _
("select * from employee", dbconn)
dbcommand.fill(dspagedata, _
"employeeall")
dbcommand = new oledbdataadapter _
("select lastname " _
& " from employee", dbconn)
dbcommand.fill(dspagedata, _
"employees")
dgemps1.datasource = _
dspagedata.tables("employeeall").defaultview
dgemps1.databind()
dgemps2.datasource = _
dspagedata.tables("employees").defaultview
dgemps2.databind()
end sub
在datagrid control中显示访问数据--www.