M
Mythran
One of the major pitfalls of the new Patterns and Practices Enterprise
Library, compared to the old version of the SQL Helper libraries, is that
the code gets blown up. Before, using the SQLHelper library, I could write
code as follows, while the new library I must do stuff following the first
example TO DO the same thing:
Please note, these are not complete examples...not worrying about exception
handling or anything else...just to get the point across and my question at
the end.
SQL Helper Example:
Public Sub Update(ByVal Row As MyTypedDataSet)
SQLHelper.ExecuteNonQueryTypedParams( _
Common.ConnectionString, _
"MyTable_Update",
Row,
New String() { "tblMyTable" },
New Object() { }
)
End Sub
Patterns and Practices Enterprise Library Example:
Public Sub Update(ByVal Row As MyTypedDataSet)
Dim db As Database = DatabaseFactory.CreateDatabase()
Dim cmd As DBCommandWrapper =
db.GetStoredProcCommandWrapper("MyTable_Update")
' Manually retrieve and set the values for each sp parameter.
cmd.AddInParameter("@MyId", DbType.Int32, Row.MyId)
cmd.AddInParameter("@Name", DbType.String, Row.Name)
cmd.AddInParameter("@Address", DbType.String, Row.Address)
cmd.AddInParameter("@City", DbType.String, Row.City)
cmd.AddInParameter("@State", DbType.String, Row.State)
cmd.AddInParameter("@Zip", DbType.String, Row.Zip)
cmd.AddInParameter("@Region", DbType.String, Row.Region)
cmd.AddInParameter("@Phone", DbType.String, Row.Phone)
cmd.AddInParameter("@DateOfBirth", DbType.DateTime, Row.DateOfBirth)
' Execute the stored procedure.
db.ExecuteNonQuery(cmd)
End Sub
So, see the difference? The latter example, we have to manually set each
parameter for the stored procedure. Why didn't they add the ability to
"sniff" out the sp to retrieve and match stored procedure parameters (or any
parameters for any type of query)?
Thanks in advance,
Mythran
Library, compared to the old version of the SQL Helper libraries, is that
the code gets blown up. Before, using the SQLHelper library, I could write
code as follows, while the new library I must do stuff following the first
example TO DO the same thing:
Please note, these are not complete examples...not worrying about exception
handling or anything else...just to get the point across and my question at
the end.
SQL Helper Example:
Public Sub Update(ByVal Row As MyTypedDataSet)
SQLHelper.ExecuteNonQueryTypedParams( _
Common.ConnectionString, _
"MyTable_Update",
Row,
New String() { "tblMyTable" },
New Object() { }
)
End Sub
Patterns and Practices Enterprise Library Example:
Public Sub Update(ByVal Row As MyTypedDataSet)
Dim db As Database = DatabaseFactory.CreateDatabase()
Dim cmd As DBCommandWrapper =
db.GetStoredProcCommandWrapper("MyTable_Update")
' Manually retrieve and set the values for each sp parameter.
cmd.AddInParameter("@MyId", DbType.Int32, Row.MyId)
cmd.AddInParameter("@Name", DbType.String, Row.Name)
cmd.AddInParameter("@Address", DbType.String, Row.Address)
cmd.AddInParameter("@City", DbType.String, Row.City)
cmd.AddInParameter("@State", DbType.String, Row.State)
cmd.AddInParameter("@Zip", DbType.String, Row.Zip)
cmd.AddInParameter("@Region", DbType.String, Row.Region)
cmd.AddInParameter("@Phone", DbType.String, Row.Phone)
cmd.AddInParameter("@DateOfBirth", DbType.DateTime, Row.DateOfBirth)
' Execute the stored procedure.
db.ExecuteNonQuery(cmd)
End Sub
So, see the difference? The latter example, we have to manually set each
parameter for the stored procedure. Why didn't they add the ability to
"sniff" out the sp to retrieve and match stored procedure parameters (or any
parameters for any type of query)?
Thanks in advance,
Mythran