c# - Debugging is giving result but not getting populated -
i have function in 1 class
public static dataset getalluppercasedtables() { //an instance of connection string created manage contents of connection string. using(var sconnection = new sqlconnection(configurationsettings.appsettings["connectionstring"])) { //to open connection. sconnection.open(); //query select tables having names in uppercased format. string selectuppercasedtables = @"select name sysobjects upper(name) collate latin1_general_bin = name collate latin1_general_bin , objectproperty(id,n'istable')=1 , objectproperty(id,n'ismsshipped')=0 "; //create command object using(var scommand = new sqlcommand(selectuppercasedtables, sconnection)) { try { //create dataset. dataset dsuppercasedtables = new dataset("information_schema.table_constraints "); //create dataadapter object. sqldataadapter da = new sqldataadapter(selectuppercasedtables, sconnection); //provides master mapping between sourcr table , system.data.datatable da.tablemappings.add("table", "information_schema.table_constraints "); //fill dataadapter. da.fill(dsuppercasedtables); //bind result combobox non primary key table names dataviewmanager dsv = dsuppercasedtables.defaultviewmanager; return dsuppercasedtables; } catch(exception ex) { //handles exception , log eventlog original message. eventlog log = new eventlog("application"); log.source = "mfdbanalyser"; log.writeentry(ex.message); return null; } { //checks whether connection still open. if(sconnection.state != connectionstate.closed) { sconnection.close(); } } } } }
and calling function in class this
public void gettableswithuppercasename() { dataset dsuppercasedtables = default(dataset); try { dsuppercasedtables = dataaccessmaster.getalluppercasedtables(); **dgresultview.datasource** = dsuppercasedtables.tables["information_schema.table_constraints"]; } catch(exception ex) { //all exceptions handled , written in eventlog. eventlog logexception = new eventlog("application"); logexception.source = "mfdbanalyser"; logexception.writeentry(ex.message); } }
i have debugged @ every required point, giving fine result till dgresultview.dataŠ«ource....
can me out!
anyway wrap sqlconnection
, dataset
, sqldataadapter
within using
block too.
Comments
Post a Comment