[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

SqlDataSource - How to execute the parameterized stored proc within?

Posted on 2006-06-13
5
Medium Priority
?
1,343 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 Ageil earned 2000 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

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 video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

650 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