database - Using OleDb.OleDb??? vb code ExecuteReader: Connection property has not been initialized -
i trying load datagridview call dgvinfo information database. quite new vb , don't understand problem lies in code @ moment.
private sub frmproductinformation_load(byval sender system.object, byval e system.eventargs) handles mybase.load dim conn new oledb.oledbconnection dim dt new datatable dim cmd new oledb.oledbcommand() dim readit oledb.oledbdatareader conn.connectionstring = "provider=microsoft.ace.oledb.12.0;data source=n:\data\gamehq.accdb" conn.open() readit = cmd.executereader() readit.read() dt.load(readit) dgvinfo.datasource = dt dgvinfo.refresh() conn.close() end sub
this code , hope able point out if i've missed something.
you have initialize cmd. assuming don't use transactions, put query , connection cmd. btw - didn't specify sql query yet:
dim conn new oledb.oledbconnection dim dt new datatable dim readit oledb.oledbdatareader conn.connectionstring = "provider=microsoft.ace.oledb.12.0;data source=n:\data\gamehq.accdb" conn.open() dim cmd new oledb.oledbcommand("select * <whatever select from>", conn) readit = cmd.executereader() readit.read() dt.load(readit) dgvinfo.datasource = dt dgvinfo.refresh() conn.close()
Comments
Post a Comment