簡體   English   中英

代碼背后的ASP.NET SqlDataSource參數聲明

[英]ASP.NET SqlDataSource parameter declaration in code behind

我在后面的代碼中實現SqlDataSource。 這是我的代碼:

var sqlDataSource = new SqlDataSource
                                {
                                    ConnectionString = _constr,
                                    SelectCommand =
                                        "SELECT One, Two FROM Foo WHERE (One = @One) AND (Two = @Two)"
                                };

如何在后面的代碼中聲明參數並為其賦予屬性值? 我試圖做這樣的事情:sqlDataSource.SelectParameteres.Add(“ @ One”,“ value”); 等等,但是拋出執行標量錯誤。

嘗試這個

sqlDataSource.SelectParameters.Add(new Parameter("One", System.TypeCode.Int32, recordNo))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM