Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Passing a sqldatasource from dal to presentation
Message
 
To
15/02/2006 00:23:22
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
ASP.NET
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01096072
Message ID:
01096417
Views:
17
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!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform