在默认窗体的头部输入如下代码: imports system.data.oledb 在按钮的click事件中: private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.click dim myconn as oledbconnection dim mycmd as oledbcommand dim myreader as oledbdatareader dim myconnstr as string dim myarray(0) as string dim i as integer
myconnstr = "provider=microsoft.jet.oledb.4.0;data source=jlgl.mdb" myconn = new oledbconnection(myconnstr) mycmd = new oledbcommand() mycmd.commandtype = commandtype.text mycmd.commandtext = "select * from jxb" mycmd.connection = myconn myconn.open() myreader = mycmd.executereader do while myreader.read myarray(i) = myreader!出厂编号 textbox1.text = textbox1.text & myarray(i) & vbcrlf redim preserve myarray(ubound(myarray) + 1) i += 1 loop label1.text = i 'i为记录条数