Hi.
I need to create a public string function in c# that returns the result of a query in a string, so far I have this:
DBConnection connection = new DBConnection();
DBDataReader reader = new DBDataReader();
Reader.SelectCommand = new DBCommand("select count (*) from courses where CTP_ID = 'Biannual Update Courses'", connection);
Reader.SelectCommand.Parameters.Add("
@CTP_ID", BoostApplication.CurrentUser);
try
{
connection.Open();
DBDataReader reader = DBCommand.ExecuteReader(CommandBehavior.CloseConnection);
while (reader.Read())
{
modules = result of query; ????
}
}
catch(Exception ex)
{
modules = ex.Message;
}
finally
{
connection.Close();
}
I know this code is wrong...can somebody show me where im going wrong or give me an alternative...many thanks in advance.
btw the query returns a single number as a result.