………………
public int Dg() {
SqlDataAdapter sda = new SqlDataAdapter("select count(*) from bbs1", myConnection);
sda.Fill(ds);
int c=这里应该怎么写,才能得到count的值;//如果不用this.ds.Tables[0].Rows.Count
return(c);
}
……………………
...全文
356打赏收藏
怎么取得这个数据值?
……………… public int Dg() { SqlDataAdapter sda = new SqlDataAdapter("select count(*) from bbs1", myConnection); sda.Fill(ds); int c=这里应该怎么写,才能得到count的值;//如果不用this.ds.Tables[0].Rows.Count return(c); } ……………………
string sql="select count(*) from screcord";
SqlCommand myCmd = new SqlCommand ("select count(*) from screcord",myConn);
myConn.open();
SqlDataReader MyReader=myCmd.ExecuteReader();
int c=myCmd.GetInt32(0);
The Better Way is——
public int Dg() {
OleDbCommand myCmd = new OleDbCommand("select count(*) from screcord",myConn);
int c=int.Parse(myCmd.ExecuteScalar().ToString());
return(c);