c# - Linq to SQL Bombing Out on DataContext -


for reason code decided stop working after doing build , not sure issue is.

public class clssaveerror {

  public clssendemail.clssendemail sendemail = new clssendemail.clssendemail();   public clssettings.clssettings settings = new clssettings.clssettings();   public clslinqtosql.k12dataclassesdatacontext dbcontext = new clslinqtosql.k12dataclassesdatacontext();       public void inserterrorintodatabase(string monsterid, string dbtable, string errormessage, string stacktrace, eventlog log)     {         clslinqtosql.k12dataclassesdatacontext dbcontext = new clslinqtosql.k12dataclassesdatacontext();             try           {               dbcontext.tblerrors err = new dbcontext.tblerrors();               err.monsterid = monsterid;               err.dbtable = dbtable;               err.errormessage = errormessage;               err.stacktrace = stacktrace;               dbcontext.tblerrors.insertonsubmit(err);               dbcontext.submitchanges();           }           catch (exception except)           {               //write error event log               log.writeentry("error! unable write error database. here details:" + "\n" +                   "exception message: " + except.message + "\n" +                   "exception stacktrace: " + except.stacktrace + "\n" +                   "database error details: " + "\n" +                   "monster id: " + monsterid + "\n" +                   "database table: " + "\n" +                   "error message: " + "\n" +                   "stacktrace: " + stacktrace);                sendemail.sendemail(settings.mailport, settings.mailhost, settings.mailtimeout, settings.mailusername, settings.mailpassword, settings.mailfrom, settings.mailto, "database error - unable update error log", "message: " + except.message + "\n" + "stacktrace: " + except.stacktrace);           }     } 

}

the error is:

'clssaveerror.clssaveerror.dbcontext' 'field' used 'type'

i know generic error not sure why occurring now. input!

you're declaring variable here:

clslinqtosql.k12dataclassesdatacontext dbcontext = new clslinqtosql.k12dataclassesdatacontext(); 

then trying use variable type here:

dbcontext.tblerrors err = new dbcontext.tblerrors(); 

if dbcontext name of type, don't declare variables same name. if isn't name of type, have no idea above line of code trying do.

your type names , variable names entirely breaking c# conventions, making code difficult read. example:

public clssendemail.clssendemail sendemail = new clssendemail.clssendemail(); 

your type names lowercase, , variable uppercase. backward standard convention. prepending cls every type name isn't helping.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -