我試圖通過一個(gè)簡(jiǎn)單的過程將數(shù)據(jù)插入到我的數(shù)據(jù)庫中,但是當(dāng)我單擊我的按鈕時(shí),我不斷返回:'必須聲明標(biāo)量變量“@categoryid”。我可以補(bǔ)充一點(diǎn),沒有變量的另一個(gè)數(shù)據(jù)添加工作沒有問題。我在哪里犯了錯(cuò)誤?插入類: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); } }}執(zhí)行按鈕: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);}存儲(chǔ)過程 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 關(guān)注
- 252 瀏覽
添加回答
舉報(bào)
0/150
提交
取消