找不到存储过程 ''

本文关键字:存储过程 找不到 | 更新日期: 2023-09-27 18:31:44

下面是我的代码:它与之前发布的问题不同。

SqlConnection con = new SqlConnection(conn);
con.Open();
SqlCommand com = new SqlCommand("INSERT into test",con);
com.CommandType = CommandType.StoredProcedure;
com.Connection = con;
com.Parameters.AddWithValue("@fileupload1", s1);
com.Parameters.AddWithValue("@path", path).ToString();
com.Parameters.AddWithValue("@Availability",Availability.SelectedValue).ToString();
        [![enter image description here][1]][1]

找不到存储过程 ''

由于命令的内容是查询语句而不是存储过程,因此请使用相关的枚举值:

// ...
SqlCommand com = new SqlCommand("INSERT into test",con);
com.CommandType = CommandType.Text;
// ...

但请记住,您的命令参数在此查询中未使用。

对于您正在使用的 SqlCommand 构造函数,第一个参数是存储过程名称或查询。您已经提供了一个查询,但您已将命令类型设置为存储过程。将第一个参数更改为存储过程名称,或将 CommandType 保留为默认值。