Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing a sqldatasource from dal to presentation
Message
 
À
15/02/2006 00:23:22
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
ASP.NET
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01096072
Message ID:
01096417
Vues:
16
I appreciate the help:

Here is my object:

public class HospitalBatch
{
public string hospid;
public string hospital;
public SqlDataSource batches;
}

Here is my method to fill it:

public HospitalBatch GetHospitalBatches(string name, string hospital)
{
HospitalBatch b = new HospitalBatch();

SqlConnection myConn = new SqlConnection(connection);
SqlCommand myCmd = new SqlCommand("select hospid,company from arcust where company = '" + hospital.Trim().ToUpper() + "'", myConn);
myConn.Open();
SqlDataReader sdr = myCmd.ExecuteReader();

while (sdr.Read())
{
b.hospid = sdr["hospid"].ToString().Trim();
b.hospital = sdr["company"].ToString().Trim();
}
sdr.Close();
myConn.Close();

b.batches.ConnectionString = connection;
b.batches.SelectCommand = "select hospid,company from arcust where company = '" + hospital.Trim().ToUpper() + "'";
b.batches.ID = "MySource";
name.Trim().ToUpper() + "' and hospid = '" + b.hospid.Trim() + "'");
return b;

Here is my call from the presentation layer:

HospitalBatch batch = new HospitalBatch();
GetBatches getBatches = new GetBatches();
batch = getBatches.GetHospitalBatches(Session["name"].ToString().ToUpper().Trim(),DropDownList1.SelectedItem.Text);

which results in the error: Object reference not set to an instance of an object...

This has been driving me nuts, this is the first time I've worked with the SQLdatasource as well. Thanks for the help!
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform