Excel Data to Data Grid View in vb6 -


hi new!

so, developing simple software vb 6.0 (yeah, know quite old). had manipulate ms excel sheet vb application. actual task display data or tables (whatever call it)provided in excel sheet data grid view.

i using adodb. here code:

  dim file_name string   dim cn new adodb.connection   dim rs new adodb.recordset  cn.open "provider=microsoft.ace.oledb.12.0;data source=" & _  file_name & ";extended properties=excel 12.0;"   if cn.state = adstateopen      msgbox "excel file connected. ", , "message"      rs.cursorlocation = aduseclient      rs.open "select * [sheet1$]", cn, 3, 3, 1 - adcmdtext      set datagrid1.datasource = rs      datagrid1.refresh      datagrid1.rebind    else: msgbox "error: excel file not connected. ", , "message"  end if  rs.close  cn.close 

but facing problem! excel data shown in data grid control. data erased after execution of line "rs.close". giving snapshot.

please help. thank you...

here image: enter image description here

you don't close recordset , connection... delete rs.close , cn.close


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -