' SQL exec ' expC1 SQL command ' expO1 Connection Public Function SQLExec(ByVal tcSQL As String, ByVal tcConnection As String) As Boolean Dim lcCommandText As String = "" Dim llSuccess As Boolean = False ' If no connection string If tcConnection.Length = 0 Then ' Get the proper definition as per the current scope If oProcess Is Nothing Then oApp.ErrorSetupControlledByTheFramework("Framework.Data.SQLExec() The connection string is empty. " + tcSQL, _ "Data") Else oProcess.ErrorSetupControlledByTheFramework("Framework.Data.SQLExec() The connection string is empty. " + tcSQL, _ "Data") End If Return False End If InitializeDataObject(tcConnection, tcSQL) Try oCommand.Connection = oConnection ' Add all command text If oCommandText.Count > 0 Then oCommand.Connection.Open() For Each lcCommandText In oCommandText oCommand.CommandText = lcCommandText oCommand.ExecuteNonQuery() Next End If oCommand.CommandText = tcSQL ' Only add the parameters if we have some oCommand.Parameters.Clear() If Not oParameters2 Is Nothing Then For Each oDataParameter In oParameters2 oCommand.Parameters.Add(oDataParameter) Next End If oDataAdapter.SelectCommand = oCommand oDataSet = New DataSet ' By default, .NET does not add the specific field length, which is needed in XML as at the other end ' someone would always get memo field instead of character field oDataAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey oDataAdapter.Fill(oDataSet) ' If we have a command text If oCommandText.Count > 0 Then oCommand.Connection.Close() ' Clear the command text collection oCommandText.Clear() End If ' Adjust to our default name oDataSet.Tables("Table").TableName = "Temp" ' Record count nCount = oDataSet.Tables("Temp").Rows.Count ' If we have at least one record If nCount > 0 Then oDataView = New DataView oDataView = oDataSet.Tables("Temp").DefaultView End If ' Clear the parameter collection If oParameters2.Count > 0 Then oParameters.Clear() oParameters2.Clear() oCommand.Parameters.Clear() End If llSuccess = True Catch loError As Exception oConnection.Close() ' Get the proper definition as per the current scope If oProcess Is Nothing Then oApp.ErrorSetup(loError, oApp.Debug(cSQL + ErrorDetail())) Else oProcess.ErrorSetup(loError, oApp.Debug(cSQL + ErrorDetail())) End If End Try Return llSuccess End Function