Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using Stored Procedure in SqlDataSource Won't Workd

1 view
Skip to first unread message

Dan Sikorsky

unread,
Jul 28, 2006, 2:50:01 PM7/28/06
to
When I hit the Test Query button in the SqlDataSource design, all the rows
come back. But when I run the website, without any changes, in the IDE, the
GridView tied to the SqlDataSoure is empty.

How do I get this working?

--
Thank you kindly,

Dan Sikorsky BA, BSCE, MCS

Ron

unread,
Jul 28, 2006, 3:57:31 PM7/28/06
to
Just a thought...
Are you using optimistic concurrency where the WHERE clause is finding no
results. I believe in this case no error is returned, but nor are any rows.

Good luck in fixing the problem.

Regards

Ron.

"Dan Sikorsky" <DanSi...@discussions.microsoft.com> wrote in message
news:CBDF6357-988C-4360...@microsoft.com...

Sean

unread,
Jul 28, 2006, 11:58:01 PM7/28/06
to
chances are you havent set up a default value for your parameter and/or set
it to a control/querystring etc etc.

so when the grid loads it wants a value for its parameter question becomes
where does it get it from?

Dan Sikorsky

unread,
Jul 29, 2006, 11:12:01 AM7/29/06
to
I don't think your comment applies ... remember, I get the rows when I do a
Test Query in th SqlDataSource control, which is the datasource of the
GridView, but no rows when I run the web app.
--
Thank you kindly,

Dan Sikorsky BA, BSCE, MCS

Dan Sikorsky

unread,
Jul 29, 2006, 11:21:01 AM7/29/06
to
I have one parameter which I get in the Page_Load event from
Request.Servervariables("LOGON_USER"), and have verified that it is set to a
loginid.

I store this loginid in a Property that stores the value in the ViewState.

I use a TextBox control that has a style=display:none, and a Text value set
to the Property.

Finally, I have a SqlDataSource SELECT control parameter set to the TextBox
control.

Should I use the Page_PreRender event instead?

--
Thank you kindly,

Dan Sikorsky BA, BSCE, MCS

Sean

unread,
Jul 29, 2006, 11:30:02 AM7/29/06
to
I think you are on the right track when thinking about the page lifecycle.
I think your best bet would be one of the events of the SQLDataSource
control or the gridview control istelf.
Perhaps the gridviews databinding event.
Also maybe you could access the Requesti.Servervariables("LOGIN_USER")
directly instead of pasing it to another control. If you follow what I am
suggesting

Dan Sikorsky

unread,
Jul 29, 2006, 11:44:01 AM7/29/06
to
I put a breakpoint on the SqlDataSource OnSelecting event and the
e.Command.Parameters[0] says the loginid is there; so it is being passed to
the Stored Procedure.

Sean

unread,
Jul 29, 2006, 11:57:02 AM7/29/06
to
Then I am at a loss other then perphaps that userid doesnt exist in the
database.
Naturally it might be that the user value simply doesnt exist in the table
but as you say you already tried it out generating a query.

I am currently investigating very mysterious problems I am having with the
SQLDatasource control referencing sproc signatures that no longer exist. Its
been very troubling.

Dan Sikorsky

unread,
Jul 31, 2006, 8:37:01 AM7/31/06
to
Post your problem and let me know where it is; I'll take a look at it.

Dan Sikorsky

unread,
Aug 4, 2006, 8:20:01 AM8/4/06
to
Fixed.

A string parameter was being passed to the stored procedure as Nothing/Null.
By setting this parameter to "" in the SqlDataSource_OnSelecting event
handler resolved the problem.

--
Thank you kindly,

Dan Sikorsky BA, BSCE, MCS

0 new messages