Results 1 to 2 of 2

Thread: datagrid/datatable

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    datagrid/datatable

    Hi there. I was just testing and playing about, i have made a function which does something i need it to do. however it uses a datagrid/datatable to get the values from

    is there another way of getting the values without having to show or use the datagrid?

    Thanks!

  2. #2
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552
    You can use DataReader instead of Adapter and use ListView
    Code:
            SqlConnection cn=new SqlConnection("user id=sa;password=password;initial catalog=northwind");
            private void Form1_Load(object sender, System.EventArgs e)
            {
                cn.Open();
                SqlCommand cm=new SqlCommand("select * from territories",cn);
                SqlDataReader dr=cm.ExecuteReader();
                while(dr.Read())
                {
                    ListViewItem li=listView1.Items.Add(dr[0].ToString());
                    li.SubItems.Add(dr[1].ToString());
                    li.SubItems.Add(dr[2].ToString());
                }
                cn.Close();
            }

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