AA,
I USE DATA READER FOR SQL STATMENT
AND I WOULD LIKE TO KNOW HOW I CAN KNOW NO OF RECORDS THAT HAS BEEN RETRIVED
AA,
I USE DATA READER FOR SQL STATMENT
AND I WOULD LIKE TO KNOW HOW I CAN KNOW NO OF RECORDS THAT HAS BEEN RETRIVED
لا تستطيع عمل ذلك بال Data Reader مباشرة، يجب أن تعد النواتج يدويا.
بالتوفيق
اقتباسمساحة تبدأ من 2000 ميجا بايت بسعر 1.99 دولار شهريا.ا
اقتباسASP.NET 1.1-2.0-3.0-3.5-4.0-4.5.1 / MVC ASP.NET / PHP 5.x / ColdFusion / MSSQL 2008 & 2012 / MYSQL
DataReader dr=cmd.ExecuteReader();
int numberOfRecords=0;
while(dr.Read())
{
//..write your code here
numberOfRecords++;
}
dr.Close();تم تعديل هذه المشاركة بواسطة محمد عبد الغنى في 27 فبراير 2006 في 19:58
' read the number of rows
Dim cmd As New SqlCommand("SELECT COUNT(*) FROM Customers", cn)
Dim totalRows As Long = CInt(cmd.ExecuteScalar())
' read the individual rows
cmd = New SqlCommand("SELECT * FROM Customers", cn)
Dim dr As SqlDataReader = cmd.ExecuteReader()إذا كنت تستخدم الـ StoredProcedure في الـ SQL Server:
اكتب داخل الإجرائية:
// Into Your Procedure select * from YOUR_TABLE select count(*) AS ItemsCount from YOUR_TABLE
/// VB.NET Code
Dim r As SqlDataReader = com.ExecuteReader()
While r.Read()
// Get Your Data Here
End While
If r.NextResult And r.Read() Then
ItemsCount = Convert.ToInt32(r("ItemsCount"))
End Ifهذا الموضوع مغلق.