S
sparks
I am building a web ap and have a webform1 an agreement.cs and a files.cs going to an access database
I am not having problems reading or writing to the database but I have hit a snag on how to keep my
variables from falling out of scope to write back to the webform.
in webform1 I am calling a fcn in files.cs to read the values for a certain agreement number and writing
those values to the variables in agreement.cs...this works.
but when I return to the calling fcn in the webform I can no longer write these variables to the text boxes for
display because it has fallen out of scope.
any help would be greatly appreciated.
thanks again
sparks
================
WEBFORM
--
private void contractread_Click(object sender, System.EventArgs e)
{
db.readAgreement(AgreementList.SelectedValue.ToString());
PanelContractInfo.Visible=true;
ContractNumber.Text=agreement.getContractNumber();
ExpDate.Text=agreement.getExpDate();
Status.Text=agreement.getStatus();
Allowed.Text=agreement.getAllowed();
}
================
files.cs
--
public Agreement readAgreement(string ContractNumber)
{
string sCommand = "Select * From tblAgreement Where ContractNumber = " + ContractNumber;
OleDbCommand cmd = new OleDbCommand(sCommand, Connection);
cmd.CommandType = CommandType.Text;
Connection.Open();
OleDbDataReader reader = cmd.ExecuteReader();
if(reader.Read())
{
return new Agreement(
reader.GetValue(0).ToString(),
reader.GetValue(1).ToString(),
reader.GetValue(2).ToString(),
reader.GetValue(3).ToString()
);
}
================
Agreement.cs
public class Agreement
{
private string ContractNumber;
private string ExpDate;
private string Status;
private string Allowed;
}
I am not having problems reading or writing to the database but I have hit a snag on how to keep my
variables from falling out of scope to write back to the webform.
in webform1 I am calling a fcn in files.cs to read the values for a certain agreement number and writing
those values to the variables in agreement.cs...this works.
but when I return to the calling fcn in the webform I can no longer write these variables to the text boxes for
display because it has fallen out of scope.
any help would be greatly appreciated.
thanks again
sparks
================
WEBFORM
--
private void contractread_Click(object sender, System.EventArgs e)
{
db.readAgreement(AgreementList.SelectedValue.ToString());
PanelContractInfo.Visible=true;
ContractNumber.Text=agreement.getContractNumber();
ExpDate.Text=agreement.getExpDate();
Status.Text=agreement.getStatus();
Allowed.Text=agreement.getAllowed();
}
================
files.cs
--
public Agreement readAgreement(string ContractNumber)
{
string sCommand = "Select * From tblAgreement Where ContractNumber = " + ContractNumber;
OleDbCommand cmd = new OleDbCommand(sCommand, Connection);
cmd.CommandType = CommandType.Text;
Connection.Open();
OleDbDataReader reader = cmd.ExecuteReader();
if(reader.Read())
{
return new Agreement(
reader.GetValue(0).ToString(),
reader.GetValue(1).ToString(),
reader.GetValue(2).ToString(),
reader.GetValue(3).ToString()
);
}
================
Agreement.cs
public class Agreement
{
private string ContractNumber;
private string ExpDate;
private string Status;
private string Allowed;
}