Hej Kolla denna artikeln om ADO.NET för ADO-programmerar: Otestad kod (utan felhantering), nedskriven direkt ifrån minnet (så det finns nog buggar :-) :Select Count
Jag undrar hur jag skriver motsvarande i C#
<code>
SQL="Select coun(*) as intNr from TABELLTEST"
Set rst = COn.Execute(SQL)
intAntalPoster = rst("intNr")
</code>
/TyronneSv: Select Count
http://www.pellesoft.se/area/articles/article.aspx?artid=364
/JohanSv: Select Count
string SQL="SELECT Count(*) FROM Tabell";
SqlConnection connection=new SqlConnection("din connectionstring);
connection.Open();
SqlCommand command=new SqlCommand(SQL,connection);
SqlDataReader reader=command.ExecuteReader();
int result=0;
if (reader.Read())
result=reader.GetInt32(0);
reader.Close();
reader=null;
command.Dispose();
command=null;
connection.Close();
connection=null;
return result;