简体   繁体   中英

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 is the dataadapter that is added so it can acces that assembly and read data from it. 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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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