Dim DBall As New SqlConnection("SQLkeyStr")
DBall.Open()
Dim cmd As New SqlCommand("Select Count(ID) from [xxx]", DBall)
Dim getNumber as Integer = CType(cmd.ExecuteScalar(),Integer)http://expert.csdn.net/Expert/topic/1279/1279997.xml?temp=4.746646E-02

解决方案 »

  1.   

    SqlConnection con=new SqlConnection();
    con.ConnectString="....";
    con.Open();
    string str;
    str= "Select Count(ID) from [xxx]";
    SqlCommand cm = new SqlCommand(str,con);int icount=int.parse(cmd.ExecuteScalar().ToString());
      

  2.   

    请问,是不是要在表中自动形成一个字段ID啊,我用的Access库。我没有调试出来啊。
    str= "Select Count(ID) from [xxx]";
    OleDbCommand cm = new OleDbCommand(str,con);string icount=cm.ExecuteScalar().ToString();
    show.Text=icount;
    没有显示出记录,何故,速帮忙!!!
      

  3.   

    你的sql可以写为select count(*) from [xxx] where ...就可以