TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Niyazi Toros
NA
41
6.7k
I cannot get rows from reader = cmd.ExecuteReader() using SP
Jun 15 2016 5:18 AM
Hi,
I have an SP like this;
/*Parameters*/
ALTER Procedure [dbo].[VerificationControl](
@Value1 nvarchar(16),
@Value2 nvarchar(4),
@Value3 nvarchar(6),
@Value4 nvarchar(10),
@Value5 nvarchar(20),
@Value6 nvarchar(20) output,
@Value7 nvarchar(20) output,
@Value8 nvarchar(50) output
)
AS
BEGIN
....
....
I am using
reader = cmd.ExecuteReader();
But I cannot get any data from
while (reader.Read())
.
When I debug I cannot enter
while (reader.Read())
loop.
// SET THE CONNECTIN VARIABLES
SqlConnection cnn;
cnn =
new
SqlConnection(connetionString);
// SET CONNECTION AND OPEN
SqlCommand cmd =
new
SqlCommand();
SqlDataReader reader;
DataTable dt =
new
DataTable();
cmd.CommandText =
"VerificationControl"
;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue(
"@Value1"
,
"AAA"
cmd.Parameters.AddWithValue(
"@Value2"
,
"BBB"
cmd.Parameters.AddWithValue(
"@Value3"
,
"CCC"
cmd.Parameters.AddWithValue(
"@Value4"
,
"DDD"
cmd.Parameters.AddWithValue(
"@Value5"
,
"EEE"
cmd.Parameters.AddWithValue(
"@Value6"
,
""
);
cmd.Parameters.AddWithValue(
"@Value7"
,
""
);
cmd.Parameters.AddWithValue(
"@Value8"
,
""
);
cmd.Connection = cnn;
cnn.Open();
reader = cmd.ExecuteReader();
while
(reader.Read())
{
string
mCusName =
""
;
mCusName = reader[0].ToString();
string
mSurName =
""
;
mSurName = reader[1].ToString();
string
mStatusCode =
""
;
mStatusCode = reader[2].ToString();
}
reader.Close();
cnn.Close();
When I look at the my SQL table that my SP works perfectly.
Any help plase?
Kind Regards
Reply
Answers (
2
)
SQLTransaction,Transactionscope & IDBtransaction
How to Read 64bit Registry for a 32bit application in c#