我试图通过一个简单的过程将数据插入到我的数据库中,但是当我单击我的按钮时,我不断返回:
'必须声明标量变量“@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)
繁星淼淼
相关分类