I’m not sure if I need to create a whole new class or what, I am very new to asp.net.
Here is my code:
public static IEnumerable<DistInfo> GetGeneralInformation ( int ClientID )
{
using ( var conn = new SqlConnection( GetConnectionString() ) )
using ( var cmd = conn.CreateCommand() )
{
conn.Open();
cmd.CommandText =
@"SELECT i.GoLiveDate, i.FirstBonusRun, i.TechFName, i.TechLName, i.TechEmail, i.TechPhone, i.WebISPFName, i.WebISPLName,
i.WebISPEmail, i.WebISPPhone, i.FullFillFName, i.FullFillLName, i.FullFillEmail, i.FullFillPhone, d.FName,
d.LName, d.HomePhone, d.Email
FROM NC_Information i
INNER JOIN Distributor d
ON d.DistID = i.ClientID
WHERE clientID = @value";
cmd.Parameters.AddWithValue( "@value", ClientID );
using ( var reader = cmd.ExecuteReader() )
{
while ( reader.Read() )
{
var distInfo = new DistInfo
{
AnticipatedLaunchDate = reader.GetDateTime( reader.GetOrdinal( "GoLiveDate" ) )
};
yield return distInfo;
}
}
}
}
gives the are you missing an assemblyt or reference. Does this mean i need to create a DistInfo class to make this work?
new DistInfo gives the same error as above.
Sorry I am very new to asp.net and don’t quite understand how to make mine work like in this post:
I keep getting this error: "Invalid attempt to call Read when reader is closed"
Do you actually have a class called
DistInfo? Does the code compile? If not, you’ll need to add a new DistInfo class that has at least aDateTime. Something like:You can add more properties in there if you need to 🙂