![]() |
How to get "SELECT COUNT(*)" return information?
Here is a part of my code...
Me.SqlCommand1.Connection = Me.SqlConnection1 SqlConnection1.Open() Me.SqlCommand1.CommandText = "SELECT COUNT(*) AS in_process FROM tbl_current_call_list WHERE repname ='" & repname & "' AND in_process='yes'" What do I use to see just the number of rows its returning? A reader or dataset or something? I just want to be able to see the number of rows, not any of the information. Thank you |
You can try this:
Dim strSQL As String Dim strCOUNT As String Dim objCommand As New OleDbCommand objCommand.Connection = objConn strSQL = "SELECT COUNT(*) AS in_process FROM tbl_current_call_list WHERE repname ='" & repname & "' AND in_process='yes'" objCommand.CommandText = strSQL objCommand.CommandType = CommandType.Text objConn.Open() strCOUNT = CType(objCommand.ExecuteScalar, String) objConn.Close() strCOUNT will hold the value of the COUNT(*) |
Yes, that worked!! Now on another page if I wanted to display the data in the rows, that would be a Dataset right?
|
that can be datareader or dataset depends upon your requirement. like this --DataReader------------------ SqlDataReader myReader = CommandName.ExecuteReader(CommandBehavior.Sequenti alAccess); while (myReader.Read()) { Response.write(myReader["Columnanme"].toString()); } myReader.Close() ---Dataset---- Dataset ds=new Dataset(); SqlDataAdapter cmd1 = new SqlDataAdapter("select * from stock",connection object); cmd1.Fill(ds,"stock"); now your dataset is filled with records.You can just bind to any controls. Thanks Nash |
All times are GMT -4. The time now is 05:10 AM. |
Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.