G
Guest
Here is the simple test stored procedure:
<code>
CREATE PROCEDURE pr_test
(
@xParam1 nvarchar(200) = null output
)
as
--set @xParam1 = newid()
select result = @xParam1
set @xParam1 = newid()
</code>
If I run the following test SQL script in Query Analyzer, I get expected
result:
declare @x nvarchar(500)
<code>
set @x = '1234'
exec pr_test @x output
select result = @x
</code>
<output>
result
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1234
(1 row(s) affected)
after
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
92CBE528-6097-48C6-A0C4-C152425D180A
(1 row(s) affected)
</output>
However, in Visual Studio .NET 2002/2003, the following code does not get
expected result:
<code>
DataSet ds = new DataSet();
this.sqlDataAdapter1.SelectCommand.Parameters["@xParam1"].Value = "1234";
this.sqlDataAdapter1.Fill(ds);
this.dataGrid1.DataSource = ds.Tables[0];
this.Text =
this.sqlDataAdapter1.SelectCommand.Parameters["@xParam1"].Value.ToString();
</code>
The output paramter @xParam1 has been setup correctly. The datagrid always
shows the value of 'result' column as 'null'.
Do I have misunderstanding of ADO.NET/SqlClient or this is simply a bug?
<code>
CREATE PROCEDURE pr_test
(
@xParam1 nvarchar(200) = null output
)
as
--set @xParam1 = newid()
select result = @xParam1
set @xParam1 = newid()
</code>
If I run the following test SQL script in Query Analyzer, I get expected
result:
declare @x nvarchar(500)
<code>
set @x = '1234'
exec pr_test @x output
select result = @x
</code>
<output>
result
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1234
(1 row(s) affected)
after
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
92CBE528-6097-48C6-A0C4-C152425D180A
(1 row(s) affected)
</output>
However, in Visual Studio .NET 2002/2003, the following code does not get
expected result:
<code>
DataSet ds = new DataSet();
this.sqlDataAdapter1.SelectCommand.Parameters["@xParam1"].Value = "1234";
this.sqlDataAdapter1.Fill(ds);
this.dataGrid1.DataSource = ds.Tables[0];
this.Text =
this.sqlDataAdapter1.SelectCommand.Parameters["@xParam1"].Value.ToString();
</code>
The output paramter @xParam1 has been setup correctly. The datagrid always
shows the value of 'result' column as 'null'.
Do I have misunderstanding of ADO.NET/SqlClient or this is simply a bug?