ASP.NET / MySQL SQLDataSource StoredProcedure

时间:2015-08-22 10:36:36

标签: c# mysql asp.net

全部,

我正在使用存储过程作为ASP.NET SQLDataSource的InsertCommand:

<asp:SqlDataSource 
    ID="_sdsData" 
    runat="server" 
    OnInserted="_sdsData_Inserted"
    ConnectionString="<%$ ConnectionStrings:_db %>"
    ProviderName="<%$ ConnectionStrings:_db.ProviderName %>" 
    InsertCommandType="StoredProcedure"
    InsertCommand="create_module">
    <InsertParameters>
        <asp:ControlParameter Name="_type" ControlID="_fvDataR$_ddlType" Type="String" PropertyName="SelectedItem.Value" />
        <asp:SessionParameter Name="_id" SessionField="USER_ID" Type="Int32" />
        <asp:Parameter Name="_code" Direction="Output" Type="String" />
    </InsertParameters>
</asp:SqlDataSource>

现在一切正常但我发现在InsertCommand 中拼错存储过程名称不会导致错误。在这种情况下,唯一的异常行为是返回参数_code的空值。

有没有办法查找存储过程调用是否已成功完成?

祝你好运,  麦克

1 个答案:

答案 0 :(得分:0)

全部,

忘记我的问题,它只需要检查事件处理程序中的异常:

protected void _sdsData_Inserted(object sender, SqlDataSourceStatusEventArgs e)
{
    if( e.Exception!=null)
        // Handle the exception
}
相关问题