p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 2.0 Basics (http://p2p.wrox.com/forumdisplay.php?f=136)
-   -   Stored Procedure Problems (http://p2p.wrox.com/showthread.php?t=39801)

Tarcash March 14th, 2006 10:50 AM

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?

jbenson001 March 15th, 2006 01:10 AM

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



Tarcash March 15th, 2006 09:20 AM

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>


Tarcash March 15th, 2006 10:48 AM

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.

jbenson001 March 15th, 2006 10:48 AM

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.


Tarcash March 15th, 2006 10:57 AM

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.

jbenson001 March 24th, 2006 05:28 PM

my sql uses "?"s i believe


MTownsend May 23rd, 2006 11:34 AM

Tarcash...Did you ever find an answer to your question, I'm having the same problem!

amyt June 16th, 2006 11:19 AM

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


BreathShadow June 19th, 2007 07:24 PM

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


All times are GMT -4. The time now is 08:05 PM.

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