Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Strange FillSchema behavior

Author  Topic 

groston
Yak Posting Veteran

61 Posts

Posted - 2006-06-28 : 11:56:48
Many of the stored procedures in may application are set as follows:

PROCEDURE MyProc
@Action nvarchar(25)
AS
if @Action = 'Action1'
[do stuff]
if @Action = 'Action2'
[do stuff]


In my code, I call this stored procedure:

da.SelectCommand.CommandText = MyProc
da.MissingSchemaAction = MissingSchemaAction.AddWithKey
da.Fill(ds, "TableName")


The odd behavior is this: The number of tables added to the DataSet is equal to the number of if statements in the stored procedure. What is happening is that the schema associated with each clause is being returned, which implies that when the schema is sought, the if statement is completely ignored.

I have tried four variants of this basic methods:
1) Use FillSchema versus MissingSchemaAction = MissingSchemaAction.AddWithKey
2) Use else if versus if in the stored procedure

Is it possible to have the the FillSchema only return the scheme for that section of the store procedure that is of interest?

Thank you.

   

- Advertisement -