| 发表于:2007-05-21 11:31:57 楼主 |
从excel导入数据到mshflexgrid,为什么只显示了第一条记录 代码如下: on error goto errorhandler dim xlsconn as new adodb.connection dim xlscmd as new adodb.command dim rs as new adodb.recordset commondialog1.showopen xlsconn.connectionstring = "provider=microsoft.jet.oledb.4.0;data source= " & commondialog1.filename & ";extended properties=excel 8.0;persist security info=false " xlsconn.open if msgbox( "确实要导入数据吗? ", vbinformation + vbyesno, me.caption) = vbyes then rs.open "select * from [sheet1$] ", xlsconn set mshflexgrid1.datasource = rs if rs.eof and rs.bof then msgbox "导入失败 ", vbinformation, me.caption else msgbox "记录已被导入 ", vbinformation, me.caption end if end if set xlsconn = nothing set rs = nothing exit sub errorhandler: msgbox err.description, vbinformation, me.caption |
|
|
|
|