Wrox Programmer Forums
|
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
 
Old March 14th, 2006, 10:50 AM
Registered User
 
Join Date: Mar 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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?
 
Old March 15th, 2006, 01:10 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

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


 
Old March 15th, 2006, 09:20 AM
Registered User
 
Join Date: Mar 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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>
 
Old March 15th, 2006, 10:48 AM
Registered User
 
Join Date: Mar 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
 
Old March 15th, 2006, 10:48 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

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.

 
Old March 15th, 2006, 10:57 AM
Registered User
 
Join Date: Mar 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
 
Old March 24th, 2006, 05:28 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

my sql uses "?"s i believe

 
Old May 23rd, 2006, 11:34 AM
Registered User
 
Join Date: May 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Tarcash...Did you ever find an answer to your question, I'm having the same problem!
 
Old June 16th, 2006, 11:19 AM
Registered User
 
Join Date: Jun 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old June 19th, 2007, 07:24 PM
Registered User
 
Join Date: Apr 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Stored Procedure Help BukovanJ SQL Language 2 October 10th, 2006 08:02 AM
Problems returning count in Stored Procedure planza SQL Language 1 December 21st, 2005 03:24 PM
stored procedure lokey VB How-To 7 June 30th, 2005 12:37 AM
Biztalk Stored Procedure problems with NULL value mtlili Biztalk 0 September 21st, 2004 05:32 AM
Stored Procedure Problems addersting SQL Language 2 October 27th, 2003 11:48 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.