Solved

SqlDataSource - How to execute the parameterized stored proc within?

Posted on 2006-06-13
5
1,332 Views
Last Modified: 2008-01-09
RE:  .NET 2.0

I'm using a "SqlDataSource" control to try and execute an INSERT stored proc. I have the "SqlDataSource" configured properly...it gets the params for the stored proc from the web forms controls. This was all setup in the wizard provided by the "SqlDataSource" control.

Now I want to click a button and execute the "SqlDataSource" so that it takes the values from the web form and uses them to execute the INSERT stored proc.

How do I just tell the "SqlDataSource" to run?
0
Comment
Question by:VirtueTech
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 5

Expert Comment

by:Jojo1771
ID: 16899461
It has 4 main functions. Which one?


Insert?

SqlDataSource1.Insert()
0
 

Author Comment

by:VirtueTech
ID: 16899752
I tried that...didn't work.

Here's the error:
"Inserting is not supported by data source 'SqlDataSource1' unless InsertCommand is specified."
0
 
LVL 9

Expert Comment

by:bele04
ID: 16899857
The sqldatasource has four main commands: Select, Insert, Update and Delete.  Which one of these did you set your stored proc to? Make sure you specify the corresponding commandtype(for Select, the SelectCommandType and so on) to StoredProcedure since you are using a stored proc and not a sql statement. then call the corresponding(for Select, SqlDataSource1.Select() and so on) method of your sqldatasource.

0
 
LVL 27

Accepted Solution

by:
Sammy earned 500 total points
ID: 16900177
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MyConnection %>"
InsertCommand="sp_insert" InsertCommandType="StoredProcedure" SelectCommand="SELECT * from mytable" OnInserted="On_Inserted" OnInserting="On_Inserting">
<InsertParameters>
<asp:Parameter Name="MyParam" >
</InsertParameters>
</asp:SqlDataSource>

take a look here for the full documentation
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.insertcommand(VS.80).aspx

HTH
0
 

Author Comment

by:VirtueTech
ID: 16903343
I was using "SelectCommand" and "SelectCommandType" instead of "InsertCommand" and "InsertCommandType"

When I used the Wizard to setup the params into the Stored Proc it put in those commands. I didn't see a place to change it otherwise. I guess you have to do it after you use the wizard. Or just do it all by hand.

Thanks guys.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question