小编use*_*485的帖子

C#中的存储过程

我想在c#中使用存储过程.我在sql server中创建存储过程,然后在程序中调用它.但是当我使用断点功能时,我才知道,当断点跳过循环时,数据不会从数据库中检索出来.

.aspx代码:

<asp:Button ID="Button1" runat="server" Text="Button" OnClick="store" />
<asp:Label ID="Label9" runat="server" Text="Label"></asp:Label>
Run Code Online (Sandbox Code Playgroud)

c#代码:

public void store(object sender, EventArgs ser)
{
    try
    {
        // c reate and open a connection object
        SqlConnection conn = Class3.GetConnection();

        // 1. create a command object identifying the stored procedure
        SqlCommand cmd = new SqlCommand("storeprocedure3", conn);

        // 2. set the command object so it knows to execute a stored procedure
        cmd.CommandType = CommandType.StoredProcedure;

        // 3. add parameter to command, which will be execute the command …
Run Code Online (Sandbox Code Playgroud)

.net c# sql t-sql stored-procedures

1
推荐指数
2
解决办法
843
查看次数

标签 统计

.net ×1

c# ×1

sql ×1

stored-procedures ×1

t-sql ×1