![](/img/trans.png)
[英]ASP.NET - parametrize query for SqlDataSource in ASP.NET code behing- VB.NET / Visual Studio 2010
[英]ASP.NET SqlDataSource Debug in Visual Studio 2010
我很難使用SqlDataSource調試asp.net Webform應用程序。 對於插入命令-
DataSource.ConnectionString = ConnectionManager.ConnectionString;
DataSource.ProviderName = ConnectionManager.ProviderName;
DataSource.InsertCommand = "INSERT INTO tblTest(ID, test1, test2, test3, test4, test5, test6, test7, test8) Values(@ID, @test1, @test2, @test3, @test4, @test5, @test6, @test7, @test8)"
我正在尋找帶有填充參數值的完整T-SQL插入字符串,例如
INSERT INTO tblTest(ID, test1, test2, test3, test4, test5, test6, test7, test8) Values(a0, 1, 2, 3, 4, 5, 6, 7, 8)
目前,我可以在
protected void DataSource_Inserted(object sender, SqlDataSourceStatusEventArgs e)
{
}
但是SqlDataSourceStatusEventArgs僅在單獨的對象中具有InsertCommand和參數集合。 將它們作為T-SQL命令放在一起非常不方便。
你們如何在Visual Studio中調試SqlDataSource?
謝謝
以下MSDN 頁面為您提供了有關如何在插入后獲取調試信息的示例。
Sub On_Inserted(ByVal sender As Object, ByVal e As SqlDataSourceStatusEventArgs)
Dim command As DbCommand
command = e.Command
' The label displays the primary key of the recently inserted row.
Label1.Text = command.Parameters("@PK_New").Value.ToString()
' Explicitly call DataBind to refresh the data
' and show the newly inserted row.
GridView1.DataBind()
End Sub 'On_Inserted
SqlDataSource實際上支持許多其他事件,您也可以在MSDN上找到它們。
最后...。也許考慮使用EntityFramework(顫抖)或其他領先的OOR工具之一,例如LLBLGEN(贏!)。 他們將數據庫抽象到一個對象模型中,從而使開發和調試變得更加容易。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.