vb.net - Uploading file to datagridview -


i have program trying upload excel file , shown in datagridview having error additional information: not find installable isam. im new vb please me

here code:

private sub button1_click(sender object, e eventargs) handles button1.click      dim con system.data.oledb.oledbconnection     dim ds system.data.dataset     dim cmd system.data.oledb.oledbdataadapter       con = new system.data.oledb.oledbconnection("provider=microsoft.jet.oledb.4.0;data source='c:\manpower.xlsx';extended properties=cc;")     cmd = new system.data.oledb.oledbdataadapter("select * [sheet2$]", con)      ds = new system.data.dataset     cmd.fill(ds)     datagridview1.datasource = ds.tables(0)      con.close() end sub 

why using oledb connection in first place? why not sqlconnection?

if can, use this:

private sub loadformdata()     dim cmdtext string     dim ds dataset     cmdtext = "select id, fname, sname, title peopletable;"     ds = getqueryresults(cmdtext)     me.datagridview1.datasource = ds.tables(0) end sub  private function getqueryresults(cmdtext string)     dim oconn new sqlconnection     oconn.connectionstring = "........."   ' connection string     dim cmd new sqlcommand(cmdtext, oconn)     dim ds new dataset()     dim da new sqldataadapter(cmd)      try         oconn.open()         da.fill(ds)         oconn.close()     catch ex exception    ' handle error way         dim errform new syserrscreen         errform.errtext.text = ex.message & vbcrlf & vbcrlf & cmdtext          errform.showdialog()         oconn.close()     end try      return ds end function 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -