 |
| ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

March 14th, 2006, 10:50 AM
|
|
Registered User
|
|
Join Date: Mar 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Stored Procedure Problems
OK, so this is going to be a really dumb question, but for some reason I can't find the answer anywhere.
I have a MsSql 2005 server and ASP.net 2.0. I have an account that has view permissions on Views, and execute permissions on stored procedures and no other access. I have a detailsview read in from the view, and I want to use the stored procedures to add/update/delete from the database, since the account that connects to the server doesn't have permissions.
When I try and set the stored procedure, it doesn't want to pass the parameters to it. I have it set up in the SqlDataSource declaration in the asp page, but I can't seem to find the proper method to bind the detailsview data to the stored procedure parameters.
Any suggestions?
|
|

March 15th, 2006, 01:10 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
What do you mean by this:?
Quote:
quote:
When I try and set the stored procedure, it doesn't want to pass the parameters to it. I have it set up in the SqlDataSource declaration in the asp page, but I can't seem to find the proper method to bind the detailsview data to the stored procedure parameters.
|
When you go through setting up the sqldatasource, you have to tell it where the parameters are coming from.
Jim
|
|

March 15th, 2006, 09:20 AM
|
|
Registered User
|
|
Join Date: Mar 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
When I set up the sqldatasource, it doesn't give me paramater options for the update/insert/delete stored procedures. It does give me options for the select statement, which is a view, not a stored procedure.
I attempted to put the parameters in myself inside the sqldatasource declaration, but I think I did it wrong:
Code:
<asp:SqlDataSource
ID="sdsTrainingClassLocations"
runat="server"
ConnectionString="<%$ ConnectionStrings:LocalDev %>"
ProviderName="<%$ ConnectionStrings:LocalDev.ProviderName %>"
SelectCommandType="Text"
SelectCommand="SELECT * FROM [vwTrainingClassLocations] WHERE ([Id] = ?)"
UpdateCommandType="StoredProcedure"
UpdateCommand="sp_TrainingClassLocations_Update"
DeleteCommandType="StoredProcedure"
DeleteCommand="sp_TrainingClassLocations_Delete"
InsertCommandType="StoredProcedure"
InsertCommand="sp_TrainingClassLocations_Insert" >
<SelectParameters>
<asp:SessionParameter DefaultValue="0" Name="Id" SessionField="TCL_Id" Type="Int64" />
</SelectParameters>
<UpdateParameters>
<asp:ControlParameter ControlID="dvTrainingClassLocations" Name="Id" PropertyName="Id" Type="Int64" />
<asp:Parameter Name="Address1" Type="String" />
<asp:Parameter Name="Address2" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="StateId" Type="Int64" />
<asp:Parameter Name="ZipCode" Type="String" />
<asp:Parameter Name="Phone" Type="String" />
</UpdateParameters>
<DeleteParameters>
<asp:Parameter Name="intId" Type="Int64" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="@Address1" Type="String" />
<asp:Parameter Name="@Address2" Type="String" />
<asp:Parameter Name="@City" Type="String" />
<asp:Parameter Name="@StateId" Type="Int64" />
<asp:Parameter Name="@Zipcode" Type="String" />
<asp:Parameter Name="@Phone" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
|
|

March 15th, 2006, 10:48 AM
|
|
Registered User
|
|
Join Date: Mar 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Oh, and I know I don't have some @'s in there before names, I have been doing tryial-and-error coding to try and get this monster to work.
|
|

March 15th, 2006, 10:48 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
I am not sure what the problem is. The only thing I can think of is that you are using mySQL and that is causing some sort of issue. If you can, download SQLExpress, it's free and will integrate better with VS2005.
|
|

March 15th, 2006, 10:57 AM
|
|
Registered User
|
|
Join Date: Mar 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I am using MsSql 2005, as I mentioned in my first post. I'm just having trouble telling sqldatasource which dataview columns go with each stored procedure parameter.
|
|

March 24th, 2006, 05:28 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
my sql uses "?"s i believe
|
|

May 23rd, 2006, 11:34 AM
|
|
Registered User
|
|
Join Date: May 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Tarcash...Did you ever find an answer to your question, I'm having the same problem!
|
|

June 16th, 2006, 11:19 AM
|
|
Registered User
|
|
Join Date: Jun 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
select the parameter option BEFORE you select the insert tab or any other tab on the screen you are talking about.
Then select the tab and you will have the option of clicking next then.
It is a bug...
|
|

June 19th, 2007, 07:24 PM
|
|
Registered User
|
|
Join Date: Apr 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi,
can you please explain this..
I have the same issues,
what to click first and what to next!!
it's confusing...
thanks
Deepak
Deepak Palkar
|
|
 |