c# - Controls are not inherited from other class -


i have function defined in 1 class:

using system; using system.collections.generic;  using system.linq; using system.text;  using system.data; using system.data.sqlclient;  using system.windows.forms; using system.configuration; using system.diagnostics; using mfdbanalyser;  namespace mfdbanalyser  {      public class dataaccessmaster:mfdbanalyser      {           //        /// <summary>         //        /// function gets list of databases present in local server.         //        /// </summary>         //        /// <returns></returns>           public static dataset getalldatabasenames()          {              sqlconnectionstringbuilder objconnectionstring = new sqlconnectionstringbuilder();             objconnectionstring.datasource = txthost.text;             objconnectionstring.userid = txtusername.text;             objconnectionstring.password = txtpassword.text;              sqlconnection sconnection = new sqlconnection(objconnectionstring.connectionstring);              //if connected give message user             lblmessage.visible = true;             lblmessage.text = "you connected sql server....";              try             {                 //to open connection.                 sconnection.open();                  //query select list of databases.                 string selectdatabasenames = @"select                                                      name                                                                                                        [master]..[sysdatabases]";                  //create command object                 sqlcommand scommand = new sqlcommand(selectdatabasenames, sconnection);                  //create data set                  dataset sdataset = new dataset("master..sysdatabases");                  //create dataadapter object                 sqldataadapter sdataadapter = new sqldataadapter(selectdatabasenames, sconnection);                 sdataadapter.tablemappings.add("table", "master..sysdatabases");                  //fill dataset                 sdataadapter.fill(sdataset);                  //bind database names in combobox                 dataviewmanager dsv = sdataset.defaultviewmanager;              }             catch(exception ex)             {                 //all exceptions handled , written in eventlog.                 eventlog logexception = new eventlog("application");                 logexception.source = "mfdbanalyser";                 logexception.writeentry(ex.message);                 messagebox.show("login failed!!", "error occured");             }                         {                 //if connection not closed close connection                 if(sconnection.state != connectionstate.closed)                 {                     sconnection.close();                 }             }         }     } } 

and called function in class this:

public void binddbdropdown()          {   dataset dstableswithoutforeignkeys = default(dataset);              try             {                 //the function getallforeignkeytables() called class pluginmanager.                 dstableswithoutforeignkeys = dataaccessmaster.getalldatabasenames();                  cmbdatabases.displaymember = "table_name";                 cmbdatabases.valuemember = "";                 cmbdatabases.datasource = dstableswithoutforeignkeys.tables["master..sysdatabases"];             }             catch(exception ex)             {                 //all exceptions handled , written in eventlog.                 eventlog logexception = new eventlog("application");                 logexception.source = "mfdbanalyser";                 logexception.writeentry(ex.message);             }         } 

but there showing error txthost etx doesn't exist , when change protected modifier of designer.cs class public showing error...

can tell me whats happening??

assuming text boxes defined in mfdbanayser class, still not able access them in getalldatabasenames function. getalldatabasenames static function , therefore not able access instance variables text boxes or other controls.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -