listview怎么连不上数据库
this.listView1.Items.Clear();//清空listview的数据string str="server=.;uid=sa;password=;database=student";
SqlConnection con=new SqlConnection(str);//建立数据库连接
string str1="select * from studnet1";
SqlCommand com=new SqlCommand(str1,con);//打开数据集
SqlDataAdapter da=com.ExecuteNonQuery();
就从这段代码开始我就搞不明白了while ( da.Read ( ) )
我打da。不出来Read {
ListViewItem li = new ListViewItem( new string[] {da["USERID"].ToString ( ), da["USERNAME"].ToString ( ),da"PASSWORD"].ToString ( ),da["POLICESTATIONID"].ToString ( ), da["ROLEID"].ToString ( ) , da"IP"].ToString ( ), da["DESCRIPTION"].ToString ( ), da["ISDELETE"].ToString ( ), da["CHINESENAME"].ToString ( ) } );
listView1.Items.Add ( li ) ;
}
//关闭数据集、关闭数据连接
da.Close();
con.Close();