简体   繁体   English

从dataadapter生成的代码中读取代码行

[英]Reading codelines from dataadapter generated code

In one of my project I have the following lines: 在我的一个项目中,我有以下几行:

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)})

The thing is that in another project I want to read the line: 问题是,在另一个项目中,我想阅读以下内容:

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)})

After refering to its assembly I write the following lines: 引用其程序集后,我编写以下行:

da.UpdateCommand.Parameters.ToString() da.UpdateCommand.Parameters.ToString()

da is the dataadapter that is added so it can acces that assembly and read data from it. da是添加的数据适配器,因此它可以访问该程序集并从中读取数据。 However the following line of code works As i wish but the upper one won't. 但是,下面的代码行如我所愿,但是上一行却行不通。

da.UpdateCommand.CommandText

is there any other solutions? 还有其他解决方案吗? Reading the line containing range of parameters? 正在读取包含参数范围的行?

Thanks 谢谢

The Parameters object in the DataAdapter is a SqlParameterCollection object. DataAdapter中的Parameters对象是SqlParameterCollection对象。 If you're looking for all the values/types, you can iterate through the items in that collection and get the values you need. 如果要查找所有值/类型,则可以遍历该集合中的项目并获取所需的值。 See the documentation to find the values you need 请参阅文档以查找所需的值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM