2011-03-10 117 views
1

在我的項目之一,我有以下行:閱讀代碼行生成的代碼

Me.SqlDeleteCommand1.CommandText = "DELETE FROM [CLASS] WHERE (([MAIN FACILITY USED] = @Original_MAIN_FACILITY_USED) " & _ 
    "AND ([START DATE] = @Original_START_DATE) AND ([CentreId] = @Original_CentreId) " & _ 
    "AND ([RowVer] = @Original_RowVer))" 
Me.SqlDeleteCommand1.Connection = Me.SqlConnection1 
Me.SqlDeleteCommand1.Parameters.AddRange(New System.Data.SqlClient.SqlParameter() {New System.Data.SqlClient.SqlParameter("@Original_MAIN_FACILITY_USED", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "MAIN FACILITY USED", System.Data.DataRowVersion.Original, Nothing), New System.Data.SqlClient.SqlParameter("@Original_START_DATE", System.Data.SqlDbType.DateTime, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "START DATE", System.Data.DataRowVersion.Original, Nothing), New System.Data.SqlClient.SqlParameter("@Original_CentreId", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "CentreId", System.Data.DataRowVersion.Original, Nothing), New System.Data.SqlClient.SqlParameter("@Original_RowVer", System.Data.SqlDbType.Timestamp, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "RowVer", System.Data.DataRowVersion.Original, Nothing)}) 

的事情是,在另一個項目中,我想讀行:

Me.SqlDeleteCommand1.Parameters.AddRange(New System.Data.SqlClient.SqlParameter() {New System.Data.SqlClient.SqlParameter("@Original_MAIN_FACILITY_USED", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "MAIN FACILITY USED", System.Data.DataRowVersion.Original, Nothing), New System.Data.SqlClient.SqlParameter("@Original_START_DATE", System.Data.SqlDbType.DateTime, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "START DATE", System.Data.DataRowVersion.Original, Nothing), New System.Data.SqlClient.SqlParameter("@Original_CentreId", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "CentreId", System.Data.DataRowVersion.Original, Nothing), New System.Data.SqlClient.SqlParameter("@Original_RowVer", System.Data.SqlDbType.Timestamp, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "RowVer", System.Data.DataRowVersion.Original, Nothing)}) 

闖民宅後到它的程序集我寫了以下幾行:

da.UpdateCommand.Parameters.ToString()

da是添加的數據適配器,因此它可以訪問該程序集並從中讀取數據。然而,下面的代碼行工作正如我所願,但上層不會。

da.UpdateCommand.CommandText 

還有其他解決方案嗎?讀取包含參數範圍的行?

謝謝

回答

1

DataAdapter中的Parameters對象是一個SqlParameterCollection對象。如果您正在查找所有值/類型,則可以遍歷該集合中的項目並獲取所需的值。查看documentation找到您需要的值