Environment versions
Network:
Windows 2003 Server
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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only