Click here to Skip to main content
15,885,537 members
Home / Discussions / C#
   

C#

 
GeneralRe: local file or public variables - what do oyu think? Pin
Jassim Rahma6-Apr-10 23:42
Jassim Rahma6-Apr-10 23:42 
GeneralRe: local file or public variables - what do oyu think? Pin
Mustafa Ismail Mustafa7-Apr-10 0:40
Mustafa Ismail Mustafa7-Apr-10 0:40 
GeneralRe: local file or public variables - what do oyu think? Pin
harold aptroot7-Apr-10 0:41
harold aptroot7-Apr-10 0:41 
AnswerRe: local file or public variables - what do oyu think? Pin
PIEBALDconsult7-Apr-10 3:49
mvePIEBALDconsult7-Apr-10 3:49 
QuestionProblem with printDocument1.PrinterSettings.Copies Pin
Reza Shojaee6-Apr-10 21:43
Reza Shojaee6-Apr-10 21:43 
QuestionScaleTransform Pin
Hema Bairavan6-Apr-10 21:24
Hema Bairavan6-Apr-10 21:24 
AnswerRe: ScaleTransform Pin
Luc Pattyn6-Apr-10 23:16
sitebuilderLuc Pattyn6-Apr-10 23:16 
QuestionNotify users Pin
Morgs Morgan6-Apr-10 20:30
Morgs Morgan6-Apr-10 20:30 
Hello guys,
I'm reading from a database using this called below:

private void GetAllMembers()//this will get members belonging to all clubs
        {
            string query = @"SELECT * FROM [member_details] INNER JOIN club_details ON club_details.memberno =  member_details.memberno WHERE [date_added] BETWEEN '" + date_from.SelectedValue.ToString() + "' AND '" + date_to.SelectedValue.ToString() + "'AND primsecconttype = '" + memb_type.SelectedValue.ToString() + "' AND [contracttype] = '" + class_type.SelectedValue.ToString() + "'";
            try
            {
                conn.Close();
                cmd = conn.CreateCommand();
                cmd.CommandText = query;
                conn.Open();
                reader = cmd.ExecuteReader();
                memb_names.Items.Clear();
                while (reader.Read())
                {
                    string firstnames = (string)reader["firstname"];
                    memb_names.Items.Add(firstnames);
                    //ProcessReportViewed();//this will call a method called UpdateReportViewed in the Manager.cs class, it will pass a user_id for this user, go there and see what goes on...
                }
                if (!reader.Read())
                {
                    error.Visible = true;
                    error.Text = "Sorry no mambers found in this range..";
                }
                //else
                //{
                    
                //}
                
                
            }
            catch (SqlException fff)
            {
                error.Visible = true;
                error.Text = "Error occured: " + fff.Message;
            }
        }


The issue is that, when I read from a database and no record
is returned I would like to let the user know. it works when
I use an if() else statement but this will only return one
record if by chance the query returns something. A while loop
returns all the records, but I AM FAILING to find a way I can
let the user know if the query returns nothing after using a while loop.

Any help please on how I can let the user know if a while loop returns
nothing???Confused | :confused:

Thanks,
Mo
AnswerRe: Notify users Pin
Greg Chelstowski6-Apr-10 21:32
Greg Chelstowski6-Apr-10 21:32 
GeneralRe: Notify users Pin
Morgs Morgan6-Apr-10 21:37
Morgs Morgan6-Apr-10 21:37 
GeneralRe: Notify users Pin
Greg Chelstowski6-Apr-10 21:42
Greg Chelstowski6-Apr-10 21:42 
Questionrecord no update Pin
mjawadkhatri6-Apr-10 20:05
mjawadkhatri6-Apr-10 20:05 
AnswerRe: record no update Pin
OriginalGriff6-Apr-10 22:25
mveOriginalGriff6-Apr-10 22:25 
AnswerRe: record no update Pin
Greg Chelstowski6-Apr-10 22:45
Greg Chelstowski6-Apr-10 22:45 
Questionplz help!!error use of unassigned local variable Pin
crisjala6-Apr-10 17:24
crisjala6-Apr-10 17:24 
AnswerRe: plz help!!error use of unassigned local variable Pin
Matt U.6-Apr-10 17:59
Matt U.6-Apr-10 17:59 
AnswerRe: plz help!!error use of unassigned local variable Pin
uraghu6-Apr-10 18:22
uraghu6-Apr-10 18:22 
AnswerRe: plz help!!error use of unassigned local variable Pin
Arun Jacob6-Apr-10 19:00
Arun Jacob6-Apr-10 19:00 
AnswerRe: plz help!!error use of unassigned local variable Pin
Morgs Morgan6-Apr-10 20:58
Morgs Morgan6-Apr-10 20:58 
AnswerRe: plz help!!error use of unassigned local variable Pin
OriginalGriff6-Apr-10 22:29
mveOriginalGriff6-Apr-10 22:29 
QuestionCreating a file and saving it to C Pin
Darrall6-Apr-10 14:09
Darrall6-Apr-10 14:09 
AnswerRe: Creating a file and saving it to C Pin
Super Lloyd6-Apr-10 14:32
Super Lloyd6-Apr-10 14:32 
AnswerRe: Creating a file and saving it to C Pin
harold aptroot6-Apr-10 15:03
harold aptroot6-Apr-10 15:03 
GeneralRe: Creating a file and saving it to C Pin
Darrall6-Apr-10 15:47
Darrall6-Apr-10 15:47 
GeneralRe: Creating a file and saving it to C Pin
Dan Mos6-Apr-10 16:49
Dan Mos6-Apr-10 16:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.