473,396 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

C#NET2008 DataReader Row Count

126 100+
Hullo Friends,
I need your help. Please help me.


I am using C#NET3.5. and DataReader.
I am trying to retrieve the Row Count from the DataReader without using WHILE DataReader.READ()

This is the error:
Cannot implicitly convert t' to 'int'. An explicit conversion exists (are you missing a cast?)


Here are the overall coding:

Expand|Select|Wrap|Line Numbers
  1. Private Sqlcommand sqlcmd;
  2. Private SqlDataReader DR;
  3. Private sqlconnection sqlconn;
  4. Private string connstr;
  5.  
  6.  
  7. Int intRowCnt = 0;
  8.  
  9. string strSqlDR = "";
  10.   strSqlDR += "Select count(*) from testInvoices ";
  11.   strSqlDR += "Where(CustomerID=n'" + strCustID + "')";
  12.  
  13. Sqlconn = new sqlConnection(connstr);
  14. sqlConn.Open();
  15. sqlCmd = new SqlCommand(strSqlDR,sqlConn);
  16. intRowCnt = sqlCmd.ExecuteScalar(); ----- error 
  17.  
  18.  
Dec 24 '10 #1
0 1249

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Kulwinder Sayal | last post by:
Hi In ASP it was so simple to get the no. of records using RecordCount. Can anyone help me how to write the no. of records my sqlquery has searched Thanks Kulwinder
2
by: Martin Raychev | last post by:
Hi all, I have the following problem: I have a private method that returns a SqlDataReader. For this to work I have not to close the DB connection in the above method. I do this only to
1
by: Brent | last post by:
I'm having a hard time wrapping my head around how to build a multi-dimensional array of n length out of a DataReader loop. Take this pseudo-code: ======================================= public...
9
by: Paul | last post by:
Does anyone have any insight on how I can get a count of the records returned after executing an ExecuteReader command? Something similar to the ..RecordCount property in Classic ASP?
3
by: William | last post by:
Can someone please explain this to me. I am not understanding why this works the way it does. The commented lines are the problems Dim oleEmp as OleDbCommand Dim myFinds as OleDataReader Dim...
5
by: robecflo | last post by:
Hi Forum, i have a problem, hope somebody can give me ideas. I'm developing with windows forms and vb.net, and oracle as a database. At this moment i have a table called amortizaciones, this table...
10
by: jimmy | last post by:
Hi again, sorry for posting two questions so close together but im working on a school project which is due in soon and running into some difficulties implementing the database parts. I have the...
4
by: =?Utf-8?B?VG9kZCBKYXNwZXJz?= | last post by:
Here is what I have: private int NationalCount() { Int32 numRecords = 0; using (SqlConnection dataConnection = new SqlConnection(GlobalVars.sqlConnString)) { SqlCommand dataCommand = new...
9
by: lenniekuah | last post by:
Hullo Good Guys, I need your help. I am very puzzled about using WITH with C#NET2008. The coding below when used in VB.NET I will be using WITH : Wth me.ListBoxCust .ColumnWidth =...
0
by: lenniekuah | last post by:
Hullo Wonderful Friends, I need your help again. Please help me. I am using WORD Template which has a table containing only 1 row and 5 columns. This row is for Column headers Text. description...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.