我試圖通過一個簡單的過程將數據插入到我的數據庫中,但是當我單擊我的按鈕時,我不斷返回:'必須聲明標量變量“@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 關注
- 232 瀏覽
添加回答
舉報
0/150
提交
取消