为了账号安全,请及时绑定邮箱和手机立即绑定

'必须声明标量变量“@categoryid”。当我尝试使用 dapper 将数据从过程插入到数据库时

'必须声明标量变量“@categoryid”。当我尝试使用 dapper 将数据从过程插入到数据库时

C#
达令说 2023-04-29 10:15:18
我试图通过一个简单的过程将数据插入到我的数据库中,但是当我单击我的按钮时,我不断返回:'必须声明标量变量“@categoryid”。我可以补充一点,没有变量的另一个数据添加工作没有问题。我在哪里犯了错误?插入类:public partial class B_Line{    public B_Line()    {        this.Budget_Scheme = new HashSet<Budget_Scheme>();    }    public int Line_id { get; set; }    public int Category_id { get; set; }    public string Name { get; set; }    public string Comment { get; set; }    public void InsertLine(int categoryID, string name, string comment)    {        using (var connection = Connection.ConnectionFactory.GetOpenConnection())        {            List<B_Line> lines = new List<B_Line>();            lines.Add(new B_Line {Category_id = categoryID, Name = name, Comment = comment});            connection.Execute("dbo.Insert_Line @categoryid, @name, @comment", lines);        }    }}执行按钮:private void Button1_Click(object sender, EventArgs e){    B_Line lines = new B_Line();    int ID_Kategorii = Int32.Parse(categoryID.Text);    lines.InsertLine(ID_Kategorii, nameLine.Text, commentLine.Text);}存储过程 MSSQL:ALTER procedure [dbo].[Insert_Lines](@categoryid int, @name nchar(40), @comment nchar(100)) as insert into BCategory (Category_id, Name, Comment) Values (@categoryid, @name, @comment)
查看完整描述

目前暂无任何回答

  • 0 回答
  • 0 关注
  • 100 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信