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(); }




Reply With Quote