Executing a stored procedure in code behind with SQLDataSource RRS feed

  • Question

  • User898650392 posted


    I need to execute a procedure with 4 input parameters. I do not need any values returned, and I need to call this procedure in code behind after a postback.

    I have tracked down some sample code and I think I have everything initialized, but the procedure is not being called. What is wrong with this code?

               DataSource.SelectCommandType = SqlDataSourceCommandType.StoredProcedure;

               DataSource.SelectCommand = "XXLP_DATA.UPD_LEA_MARKUP";
                DataSource.SelectParameters.Add("@LocationCode", TypeCode.String, strFeatID);
                DataSource.SelectParameters[0].Direction = ParameterDirection.Input;
                DataSource.SelectParameters.Add("@Type", TypeCode.String, "CREATE");
                DataSource.SelectParameters[1].Direction = ParameterDirection.Input;
                DataSource.SelectParameters.Add("@Null", TypeCode.String, "");
                DataSource.SelectParameters[2].Direction = ParameterDirection.Input;
                DataSource.SelectParameters.Add("@Null", TypeCode.String, "");
                DataSource.SelectParameters[3].Direction = ParameterDirection.Input;

    Compiler Error Message: CS1501: No overload for method 'Select' takes 0 arguments

    Sunday, January 8, 2012 11:18 PM


All replies

  • User522486851 posted

    What is the DataSoruce object?

    if your database is MsSql you can use SqlCommand object.

    more detail here


    Sunday, January 8, 2012 11:55 PM
  • User898650392 posted

    It is the standard asp sqldatasource control, like this:

              ConnectionString="<%$ ConnectionStrings:MyNorthwind%>">
    Using similar syntax i have run insert, update, and delete statements. Just can't figure out how to run a darn stored procedure. 
    Sunday, January 8, 2012 11:59 PM
  • User522486851 posted

    hey you shold pass a argument for select method following the syntax

    public IEnumerable Select(
     DataSourceSelectArguments arguments
    More detail you can find here 
    Hope this help :)
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 9, 2012 4:58 AM
  • User898650392 posted



    to the end of my existing code worked. thank you for your time.

    Monday, January 9, 2012 12:24 PM