我有一個.NET項目正在接收數據,處理它,然後將其寫入到SQLServer數據庫。假設我有以下代碼。 Private Sub InsertRecord(val1 As Integer, val2 As Integer, ByRef dbConnection As Data.SqlClient.SqlConnection)
Dim cmd As SqlCommand = Nothing
中的動態where子句我正在嘗試構建SqlCommand的where子句。 一些類似這樣的 myCommand.CommandText = "SELECT * " +
"FROM TABLE1 " +
"@whereClause";
//I build up the where clause with a StringBuilder
myCommand.
任何人都可以告訴我,是否有充分的理由使用下面的兩個代碼塊之一而不是另一個? using (SqlTransaction mySqlTransaction = mySqlConnection.BeginTransaction)
{
using (SqlCommand mySqlCmd =
new SqlCommand("First of many SQL statements