using(SqlConnection connp=new SqlConnection(connString))
{
SqlCommand cmd=new Sqlcommand("select * from customers",conn);//查询Customers表
cmd.Connection.Open()//打开数据库连接
SqlDataReader reader=cmd.ExecuteReader();
While(reader.Read())//循环读取数据
//将companyname的值添加到CustomerList中
CustomerList.Items.add(read["companyname"].Tostring());
reader.Close();//关闭数据库连接
}