Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a table having name tblReceivedRequest. Request have a status like pending, recieved, failed etc. i want to get count for each status.


I cant able to get it on my vb.net application.


I written a store procedure for it. it gives me a row having a counts for each status.
the store procedure code as follows

RETURN SELECT	(SELECT COUNT(*) FROM tblRequest WHERE RequestStatusID=0 AND RequestTypeID =1)as ScheduleMail,
		(SELECT COUNT(*) FROM tblRequest WHERE RequestStatusID=0 AND RequestTypeID =0)AS ScheduleSMS,
		(SELECT COUNT(*) FROM tblRequest WHERE RequestStatusID=1 AND RequestTypeID =1)AS SentMail,
		(SELECT COUNT(*) FROM tblRequest WHERE RequestStatusID=1 AND RequestTypeID =0)AS SentSMS,
		(SELECT COUNT(*) FROM tblRequest WHERE RequestStatusID=2 AND RequestTypeID =1)AS ExpiredMail,
		(SELECT COUNT(*) FROM tblRequest WHERE RequestStatusID=2 AND RequestTypeID =0)AS ExpiredSMS,
		(SELECT COUNT(*) FROM tblRequest WHERE RequestStatusID=3 AND RequestTypeID =1)AS FailedMail,
		(SELECT COUNT(*) FROM tblRequest WHERE RequestStatusID=3 AND RequestTypeID =0)AS FailedSMS


What I have tried:

I written a store procedure for it. it gives me a row having a counts for each status.

the above sql code return a row when I execute it on SQL management studio.

I want to get it using dataReader using vb.net
Posted
Updated 15-May-16 20:22pm
v2

1 solution

Try:
VB
Using con As New SqlConnection(strConnect)
	con.Open()
	Using cmd As New SqlCommand("spMyStoredProcedure", con)
        cmd.CommandType = CommandType.StoredProcedure
		Using reader As SqlDataReader = cmd.ExecuteReader()
			If reader.Read()
				Dim scheduleMail As Integer = CInt(reader("ScheduleMail"))
				Dim scheduleSMS As Integer = CInt(reader("ScheduleSMS"))
				...
			End If
		End Using
	End Using
End Using
 
Share this answer
 
Comments
Vikas Hire 16-May-16 2:41am    
Reader does not reads row
OriginalGriff 16-May-16 2:44am    
What does happen?
Remember, we can't see your screen, access your HDD or read your mind - and we have no access to your DB to try anything! So show us exactly the code you tried, and explain what happened that you didn't expect, or didn't happen that you did!
Vikas Hire 16-May-16 2:48am    
got it. I am Deleted RETURN Keyword in my store procedure it get workout
Vikas Hire 16-May-16 2:48am    
Thank You so much..
OriginalGriff 16-May-16 2:53am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900