.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

modify sql data source command in code behind

Posted By:      Posted Date: October 18, 2010    Points: 0   Category :ASP.Net

i had a requirement for dynamic sorting so i wanted to assign order by.. dynamically depending on what column is clicked for sorting

i tried to modify the sql data source command 

in ds selecting event

by using


but it doesnt work as it always picks up selectCommand specified in aspx page

View Complete Post

More Related Resource Links

Toolbox: Data Snapshots, Subversion, Source Code Organization and More


If you want to save, organize, and annotate snapshots of your database data, find an easy way to install and configure Subversion, and automate the organization of your source code, then you'll want to read more about these latest tools.

Scott Mitchell

MSDN Magazine August 2009

Adding source redirect code to end of a URL which used a dynamic data value

I'm trying to add some source redirect code to the end of a URL in a Data Form Web Part on a simple SharePoint aspx page. This is the basic url: /itservices/helpdesk/Lists/Service%20Requests/DispForm.aspx?ID={@ID} However I want to add a source redirect to the end of the URL so that it returns to a particular page rather than the list's default page. I have tried all of the following: /itservices/helpdesk/Lists/Service%20Requests/DispForm.aspx?ID={@ID}&source=/itservices/Pages/MyOverview.aspx That causes an error in the web part stating "This Web Part does not have a valid XSLT stylesheet: Error; A semi colon character was expected". I tried replacing the ampersand with the URL encoded character: /itservices/helpdesk/Lists/Service%20Requests/DispForm.aspx?ID={@ID}%26source=/itservices/Pages/MyOverview.aspx But when opening from this URL the form contains no data. What am I missing or can this not be done? Thanks.  

How to set items from Select Command in Data Source to populate textboxes


I need to know how to get the  items from a Select Command in a Data Source to populate textboxes. For instance in the Select statement below I want to set the textbox for First Name equal to the item in the Select Command highlighted below:


 Protected Sub MHGrid_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MHGrid.SelectedIndexChanged
        Me.Table1.Visible = True

        Me.txtFirstName.Text = (1)

    End Sub


The data source control failed to execute the insert command


Hi All,

I have create table in SQL 2005 and retrive its data in to sharepoint  with the help of Database connection option through Sharepoint Designer. When configuring the connection i have selected a custom quer with stored procedure option and from the dropdown option selected the insert stored procedure everything is ok.

Stored Procedure
CREATE PROCEDURE ChangeTable_insert

 @PROJECT varchar(50) ,

INSERT INTO [dbo].[ChangeTable]





i have created new aspx page in Sharepoint Designer from the datasource details-->Insert selected fields as-->selected new item form and saved this page.
When i opened this page in to browser and try to save data it gives an below error
Go back to site 
Error: "The data source control failed to execute the insert command.
 Troubleshoot issues with Windows SharePoint Services."

please help me. i have to save data to sql database through sharepoint

thanks in advance

The data source control failed to execute the insert command


In SharePoint Designer 2007 I'm trying to customize the edit form that you get when you create a list item in a SharePoint 2007 list (EditForm.aspx). I took the following steps:

1.       Open the site in SharePoint Designer 2007.

2.       Browse to the list and open the 'NewForm.aspx' web form.


Copy and modify Data Source crashes SPD 2010 - List Threshold error


When I try to copy and modify a data source, I get a server error that the operation is prohibited because it exceeds the list view threshold, but I only have 10 items in my list, well below the default threshold.  I get the same error if I try to create a new page from master.  Anybody run across this one?

Confirmed the threshold with my administrator and even upped it to 10,000 but that did not help.

"The data source control failed to execute the insert command." when inserting to sql table with tri



I have a data view web part that inserts a new record into a sql table. This works fine.

I have now needed to add a trigger to the sql table that sends an email when a new record is inserted (the code for which works fine) but now my insert fails with 'The data source control failed to execute the insert command.'.

If I disable the trigger the form works fine again.

Any ideas what could be causing this?


Cannot submit an infopath 2007 data source to sql database using managed code - C#.


Is this possible?  I can submit the data source just fine using custom action rules either from a submit button on the form or from the submit button from the tool bar.

But when I try to use C# nothing below works, Main Connection is my data source.  I get unhandled exception errors when I run the form in debug

AdoSubmitConnection sc = (AdoSubmitConnection)this.DataConnections["Main Connection"];

WebServiceConnection sc = (WebServiceConnection)this.DataConnections["Main Connection"];

FileSubmitConnection sc = (FileSubmitConnection)this.DataConnections["Main Connection"];

However I can send an email just fine using ;

EmailSubmitConnection sc = (EmailSubmitConnection)this.DataConnections["Email Connection"];


Any help would be greatly appreciated



Microsoft StyleCop: Source Code Analyzer for C#

StyleCop is similar in many ways to Microsoft Code Analysis (specifically FxCop), but there are some important distinctions. FxCop performs its analysis on compiled binaries, while StyleCop analyzes the source code directly. For this reason, FxCop focuses more on the design of the code, while StyleCop focuses on layout, readability and documentation. Most of that information is stripped away during the compilation process, and thus cannot be analyzed by FxCop.

C# and XML Source Code Documentation

Through many years of enterprise level software development and consulting, I became critically aware of the importance of good source code documentation, and several years ago when I began working with the first release of Visual Studio .NET beta 1 and found C# provided built-in support for inline XML code documentation, I was thrilled.

Any plans on releasing the source code for WebMatrix itself?


I tried reflecting into WebMatrix.exe but was unable.  I'm interested on how you integrated the WPF Ribbon & the Office-style sidebar.

How to install the Css Friendly Control Adapter Source Code


Hi guys really new to ASP.NET I was trying to install the CSS Friendly control adapter but for some reason the instructions on the website seems outdated. I downloaded all the files (Source Code, DLL, Browser) I believe I need to add the DLL file to my website's Bin folder and the Browser file to the APP_Browsers folder is this correct? After I place this files how to I get it working? what do I have to do?

Also if I want to create a new DLL file from the Source code how do I do these? I opened the web-site with Visual Studio 2008 and I can see all the files in the solution explorer? But how do I compile this to a DLL file? I tried doing a build solution but all I get is an .sln file???

Any help would be greatly appreciated

Thanks in advance


Under the Table: How Data Access Code Affects Database Performance


In this article, the author delves into some commonly used ways of writing data access code and looks at the effect they can have on performance.

Bob Beauchemin

MSDN Magazine August 2009

Smart Storage: Protect Your Data Via Managed Code And The Windows Vista Smart Card APIs


Smart cards are a compelling alternative to the reliance on passwords, which are the weakest link in authentication systems. Get the Windows smart card programming basics here.

Dan Griffin

MSDN Magazine November 2006

Toolbox: Protecting Code, Persisting Data, and More


This month obfuscating your code, persisting your data, and a good read on SQL Server 2005.

Scott Mitchell

MSDN Magazine October 2006

Know Thy Code: Simplify Data Layer Unit Testing using Enterprise Services


If you want to employ unit testing and test-driven development techniques in your database application development process, you'll have different factors to consider than you do when you're not involving a database. For example, you have to maintain a consistent state within the database and be able to roll back transactions when necessary. This article shows you how to get the best of unit testing for your database apps in a safe, usable manner.

Roy Osherove

MSDN Magazine June 2005

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend