Saturday, 15 May 2010

How to call a query from MS Access 2010 (.accdb) within VB.Net 2010? -



How to call a query from MS Access 2010 (.accdb) within VB.Net 2010? -

i have code populates datagridview info ms access:

dim con new oledbconnection dim ds new dataset dim da oledb.oledbdataadapter dim sql string sql = "select * mytable case_no=?" seek con.connectionstring = "provider=microsoft.ace.oledb.12.0;data source=sample.accdb;persist security info=true;jet oledb:database password=dbadmin2010" con.open() dim cmd oledbcommand = new oledbcommand(sql, con) da.selectcommand = cmd cmd.parameters.addwithvalue("case_no", case_no) dim ds dataset = new dataset da.fill(ds, "case info") datagridview1.datasource = ds.tables("case info") grab ex exception msgbox(ex.message) end seek

now had finished creating query design view within ms access itself, there way phone call query , retrieve results datagridview?

just utilize query name , set command type, example, in add-on have, can utilize next notes:

try con.connectionstring = enter_connection_string_here con.open() cmd.connection = con cmd.commandtype = commandtype.storedprocedure cmd.commandtext = "nameofquery" da.selectcommand = cmd cmd.parameters.addwithvalue("case_no", case_no) da.fill(ds, "case info")

vb.net ms-access

No comments:

Post a Comment