asp.net - Spreadsheet connection in vb web app -
my client wants price list on website. i'm trying use spreadsheet (.xlsx) data source limit processing of data before appears on website.
the site running on iis 7. server windows server 2008. i've updated .net framework on 4.0 well.
it doesn't have office packages installed on it, , have hunch thats problem lies, i'd sure.
heres error text i'm getting:
system.invalidoperationexception: 'microsoft.jet.oledb.4.0' provider not registered on local machine. @ system.data.oledb.oledbserviceswrapper.getdatasource(oledbconnectionstring constr, datasourcewrapper& datasrcwrapper) @ system.data.oledb.oledbconnectioninternal..ctor(oledbconnectionstring constr, oledbconnection connection) @ system.data.oledb.oledbconnectionfactory.createconnection(dbconnectionoptions options, object poolgroupproviderinfo, dbconnectionpool pool, dbconnection owningobject) @ system.data.providerbase.dbconnectionfactory.createnonpooledconnection(dbconnection owningconnection, dbconnectionpoolgroup poolgroup) @ system.data.providerbase.dbconnectionfactory.getconnection(dbconnection owningconnection) @ system.data.providerbase.dbconnectionclosed.openconnection(dbconnection outerconnection, dbconnectionfactory connectionfactory) @ system.data.oledb.oledbconnection.open() @ products.page_load(object sender, eventargs e) in c:\hostingspaces\webbuddies\waterinc.webbuddies.co.za\wwwroot\products.aspx.vb:line 14
heres code:
protected sub page_load(byval sender object, byval e system.eventargs) handles me.load ' here's connection string defined in web.config: ' <connectionstrings> ' <add name="xlsx" connectionstring="provider=microsoft.jet.oledb.4.0;data source=app_data/pricelist.xlsx;extended properties=excel 8.0;" /> ' </connectionstrings> dim con new oledbconnection(configurationmanager.connectionstrings("xlsx").connectionstring) ' spreadsheet has 4 sheets in it, 1 each category on client's pricelist. try con.open() dim dswater dataset dim dawater new oledbdataadapter dawater.selectcommand = new oledbcommand("select * water", con) dim dsjuice dataset dim dajuice new oledbdataadapter dajuice.selectcommand = new oledbcommand("select * fruitjiuce", con) dim dsmix dataset dim damix new oledbdataadapter damix.selectcommand = new oledbcommand("select * muffinmix", con) dim dsmisc dataset dim damisc new oledbdataadapter damisc.selectcommand = new oledbcommand("select * miscellaneous", con) dawater.fill(dswater, "water") dajuice.fill(dsjuice, "fruitjuice") damix.fill(dsmix, "muffinmix") damisc.fill(dsmisc, "miscellaneous") rptwater.datasource = dswater : rptwater.databind() rptjuices.datasource = dsjuice : rptjuices.databind() rptmixes.datasource = dsmix : rptmixes.databind() rptmisc.datasource = dsmisc : rptjuices.databind() con.close() catch ex exception errormessage = ex.tostring lblresponse.text = "could not connect 1 or more data sources required display " & _ "pricelist. please contact webmaster." & vbcrlf & errormessage lblresponse.forecolor = drawing.color.red end try end sub edit 1
since posting have installed 2007 office driver on server link in 1st answer, , have modified connection string per 2nd answer:
<connectionstrings> <add name="xlsx" connectionstring="provider=microsoft.ace.oledb.12.0; data source=app_data/pricelist.xlsx; extended properties=excel 12.0 xml; hdr=yes;"/> </connectionstrings>
you need have 2007 office driver installed work.
Comments
Post a Comment