hi, iam using vb.net code
this is my stored procedure in sql server.

create proc t1 (@q as int)
as
select * from test where id=@q

GO

------

i am using vb.net code below like this

Dim s As SqlClient.SqlDataReader
Me.SqlCommand1.Parameters("@RETURN_VALUE").Direction =
ParameterDirection.Output
Me.SqlCommand1.Parameters("@q").Value = 1
s = SqlCommand1.ExecuteReader
Do Until s.Read
MsgBox(s(0))
Loop

iam wondering how come iam not able to display msgbox, even though the data
is there.
any changes in the code need or
any changes in the stored procedure.

where should i change...

thanks

Re: command object by Mary

Mary
Wed Aug 18 09:26:02 CDT 2004

What are you trying to achieve here? I find your code very confusing.
Your stored procedure takes an input parameter and doesn't explicitly
set the return value, it simply returns a result set. You're setting
@q (the input parameter) as an output parameter. Since you don't have
SET NOCOUNT ON in the sproc, it also returns the rows affected, aka
the done in proc message.

--Mary

On Wed, 18 Aug 2004 06:51:02 -0700, "rt"
<rt@discussions.microsoft.com> wrote:

>hi, iam using vb.net code
>this is my stored procedure in sql server.
>
>create proc t1 (@q as int)
>as
>select * from test where id=@q
>
>GO
>
>------
>
>i am using vb.net code below like this
>
> Dim s As SqlClient.SqlDataReader
> Me.SqlCommand1.Parameters("@RETURN_VALUE").Direction =
>ParameterDirection.Output
> Me.SqlCommand1.Parameters("@q").Value = 1
> s = SqlCommand1.ExecuteReader
> Do Until s.Read
> MsgBox(s(0))
> Loop
>
>iam wondering how come iam not able to display msgbox, even though the data
>is there.
>any changes in the code need or
>any changes in the stored procedure.
>
>where should i change...
>
>thanks
>
>


Re: command object by C

C
Wed Aug 18 09:44:38 CDT 2004

Do Until loops until the condition is true. So your loop is never entered
if s.Read() returns true, that is, there is data present.

Instead try Do While or simply a While loop which looks like

While s.Read()
' statements
End While

--
Addison Ritchie, MCSD.NET
Ritch Consutling, Inc.

"rt" <rt@discussions.microsoft.com> wrote in message
news:9A0F2AD4-E2AF-42EC-9F62-15785B50656C@microsoft.com...
> hi, iam using vb.net code
> this is my stored procedure in sql server.
>
> create proc t1 (@q as int)
> as
> select * from test where id=@q
>
> GO
>
> ------
>
> i am using vb.net code below like this
>
> Dim s As SqlClient.SqlDataReader
> Me.SqlCommand1.Parameters("@RETURN_VALUE").Direction =
> ParameterDirection.Output
> Me.SqlCommand1.Parameters("@q").Value = 1
> s = SqlCommand1.ExecuteReader
> Do Until s.Read
> MsgBox(s(0))
> Loop
>
> iam wondering how come iam not able to display msgbox, even though the
data
> is there.
> any changes in the code need or
> any changes in the stored procedure.
>
> where should i change...
>
> thanks
>
>
>