[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SqlDataSource - How to execute the parameterized stored proc within?

Posted on 2006-06-13
5
Medium Priority
?
1,350 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
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Loops Section Overview
Suggested Courses
Course of the Month18 days, 23 hours left to enroll

834 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