Using Stored Procedure in SqlDataSource Won't Workd

G

Guest

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?
 
R

Ron

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.
 
G

Guest

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?
 
G

Guest

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


Ron said:
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.
 
G

Guest

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?
 
G

Guest

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
 
G

Guest

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.
 
G

Guest

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 said:
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.


--
Thank you kindly,

Dan Sikorsky BA, BSCE, MCS


Sean said:
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
 
G

Guest

Post your problem and let me know where it is; I'll take a look at it.

--
Thank you kindly,

Dan Sikorsky BA, BSCE, MCS


Sean said:
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 said:
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.


--
Thank you kindly,

Dan Sikorsky BA, BSCE, MCS


Sean said:
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

:

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


:

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?


:

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?
 
G

Guest

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.
 
Joined
Oct 31, 2007
Messages
1
Reaction score
0
Re: Using store procedure with sqldatasource

This just happened to me. I found that setting the convertemptystring property to false, in the Configure Datasource, Define Parameters screen, solved the problem. By default this property is true.

Thanks for your sharing.

Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top