Results 1 to 4 of 4

Thread: [Solved] Use of unassigned local variable "dr"

Threaded View

  1. #1

    Thread Starter
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552

    Resolved [Solved] Use of unassigned local variable "dr"

    Why is she (C#) treating "dr" as an unassigned local variable? Or am I missing something?
    Code:
                natureofcollections n=new natureofcollections();
                SqlDataReader dr;
                try
                {
                    monkey.sql.sqlconnection.openconnection(cn);
                    dr=new monkey.sql.sqlcommand("selectallnatureofcollections",cn).executereader();
                    while(dr.Read())
                    {
                        n.add(new natureofcollection(dr[0].ToString(),
                            dr[1].ToString(),
                            dr[2].ToString()));
                    }
                }
                catch(Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    dr.Close();
                    monkey.sql.sqlconnection.closeconnection(cn);
                }
                return n;
    Thank you.
    Last edited by brown monkey; Nov 16th, 2004 at 04:12 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width