question

shyam229 avatar image
shyam229 asked

How to count columns of table in sql server 2008 using C#?

Hi, I am writing a program in C# and I connected the table with it. I am using SQL server 2008 and I want to know, Using C# how can i count the rows in one perticular table in the database. Thank you, Shyam
sql-server-2008c#
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ThomasRushton avatar image
ThomasRushton answered
SELECT COUNT(1) FROM or (I think) SELECT rowcnt from sysindexes where id = object_id('') and indid in (0,1) or, from the C# side, look at the RecordCount (or is it RowCount) property of the recordset object? I've not done this stuff for *years*...
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ThomasRushton avatar image ThomasRushton ♦♦ commented ·
sorry, I've been stuck in conf calls all week, and my head is full of clouds...
0 Likes 0 ·
xiaoyuandlg avatar image
xiaoyuandlg Suspended answered
I thought this to be a question relating to the [C# grid column][1], you may get some insights since you do the reading of the thing. [1]: http://www.kettic.com/winforms_ui/csharp_guide/gridview_column.shtml
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.