Why do these errors occur, and how can they be fixed?
Error 1 Expected class, delegate, enum, interface, or struct C:\Documents and Settings\agordon\My Documents\Visual Studio 2008\Projects\lomdb\EnterData\DataEntry\DAL.cs 9 19 EnterData
Error 2 Expected class, delegate, enum, interface, or struct C:\Documents and Settings\agordon\My Documents\Visual Studio 2008\Projects\lomdb\EnterData\DataEntry\DAL.cs 11 54 EnterData
Error 3 Expected class, delegate, enum, interface, or struct C:\Documents and Settings\agordon\My Documents\Visual Studio 2008\Projects\lomdb\EnterData\DataEntry\DAL.cs 25 23 EnterData
Error 4 Expected class, delegate, enum, interface, or struct C:\Documents and Settings\agordon\My Documents\Visual Studio 2008\Projects\lomdb\EnterData\DataEntry\DAL.cs 27 57 EnterData
Error 5 Type or namespace definition, or end-of-file expected C:\Documents and Settings\agordon\My Documents\Visual Studio 208\Projects\lomdb\EnterData\DataEntry\DAL.cs 39 9 EnterData
Error 8 The name ‘PopulateMainForm’ does not exist in the current context C:\Documents and Settings\agordon\My Documents\Visual Studio 2008\Projects\lomdb\EnterData\DataEntry\WebForm1.aspx.cs 25 53 EnterData
Error 9 The name ‘PopulateBatchTable’ does not exist in the current context C:\Documents and Settings\agordon\My Documents\Visual Studio 2008\Projects\lomdb\EnterData\DataEntry\WebForm1.aspx.cs 26 50 EnterData
Error 10 The name ‘PopulateProblemTable’ does not exist in the current context C:\Documents and Settings\agordon\My Documents\Visual Studio 2008\Projects\lomdb\EnterData\DataEntry\WebForm1.aspx.cs 27 54 EnterData
Error 11 The name ‘PopulateSpecimenTable’ does not exist in the current context C:\Documents and Settings\agordon\My Documents\Visual Studio 2008\Projects\lomdb\EnterData\DataEntry\WebForm1.aspx.cs 28 56 EnterData
I am keeping the IList classes in a file called DAL.cs in the same directory:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using RadarGraphInsertDLL;
namespace EnterData.DataEntry
{
public static IList<LOMDLL.Lom_Batch> PopulateBatchTable()
{
IList<LOMDLL.Lom_Batch> BatchTable = new IList<LOMDLL.Lom_Batch>();
try
{
}
catch (Exception e)
{
}
return BatchTable;
}
public static IList<LOMDLL.Lom_Problem> PopulateProblemTable()
{
IList<LOMDLL.Lom_Problem ProblemTable = new IList<LOMDLL.Lom_Problem();
try
{
}
catch (Exception e)
{
}
return ProblemTable;
}
public static IList<LOMDLL.Lom_Specimen> PopulateSpecimenTable()
{
IList<LOMDLL.Lom_Specimen SpecimenTable = new IList<LOMDLL.Lom_Specimen();
try
{
}
catch (Exception e)
{
}
return SpecimenTable;
}
public static LOMDLL.Main_Lom_Form PopulateMainForm()
{
//populate class
LOMDLL.Main_Lom_Form TheForm = new LOMDLL.Main_Lom_Form();
try
{
TheForm.lom_number = lom_numberTextBox.Text.ToInt();
TheForm.identified_by = identified_byTextBox.Text;
TheForm.occurrence_date = occurrence_dateTextBox.Text.ToDateTime();
//TheForm.pre_contact = pre_contactTextBox.Text; //need to create this texdtbox
//TheForm.pre_practice_code = pre_practice_codeTextBox.Text; //create this
TheForm.report_by = report_byTextBox.Text;
TheForm.report_date = report_dateTextBox.Text.ToDateTime();
TheForm.section_c_comments = section_c_commentsTextBox.Text;
TheForm.section_c_issue_error_identified_by = section_c_issue_error_identified_byTextBox.Text;
TheForm.section_d_investigation = section_d_investigationTextBox.Text;
TheForm.section_e_corrective_action = section_e_corrective_actionTextBox.Text;
TheForm.section_f_comments = section_f_commentsTextBox.Text;
}
catch(Exception e)
{
}
return TheForm;
}
}
Your code isn’t valid. You cannot declare methods at namespace scope, they must reside in a class (or some other type) definition.