Public _SQLTransact As SqlTransaction
Function __Simpan() As Boolean
Dim dtUpdate As Date
Dim strNomor As String = __GetNomor()
dtUpdate = _uniGudang._GetDateTime
_SQLTransact = _SQLConnection.BeginTransaction
_SQLCommand.Transaction = _SQLTransact
Try
__Simpan = True
With _SQLCommand
.CommandText = "uniMutasiGudang_INSERT"
.Parameters.Clear()
.Parameters.Add("@MerekID", SqlDbType.Int).Value = intMerekID
.Parameters.Add("@TipeID", SqlDbType.Int).Value = intTipeID
.Parameters.Add("@WarnaID", SqlDbType.Int).Value = intWarnaID
.Parameters.Add("@TahunProduksi", SqlDbType.NVarChar, 4).Value = txtTahunProduksi.EditValue
.Parameters.Add("@NomorRangka", SqlDbType.NVarChar, 20).Value = cboNomorRangka.EditValue
.Parameters.Add("@NomorMesin", SqlDbType.NVarChar, 20).Value = txtNomorMesin.Text
.Parameters.Add("@Tanggal", SqlDbType.DateTime).Value = dtTanggal.EditValue
.Parameters.Add("@Nomor", SqlDbType.NVarChar, 16).Value = strNomor
.Parameters.Add("@DariKepadaCabangID", SqlDbType.Int).Value = cboDariKepadaID.Text
.Parameters.Add("@DariKepada", SqlDbType.NVarChar, 50).Value = cboDariKepada.Text
.Parameters.Add("@PetugasGudang", SqlDbType.NVarChar, 20).Value = txtPetugasGudang.Text
.Parameters.Add("@Driver", SqlDbType.NVarChar, 20).Value = txtDriver.Text
.Parameters.Add("@Lokasi", SqlDbType.NVarChar, 20).Value = txtLokasiParkir.Text
.Parameters.Add("@Keterangan", SqlDbType.NVarChar, 255).Value = txtKeterangan.Text
.Parameters.Add("@Status", SqlDbType.NVarChar, 20).Value = "OPEN"
.Parameters.Add("@FDate", SqlDbType.DateTime).Value = dtUpdate
.Parameters.Add("@FUserID", SqlDbType.NVarChar, 20).Value = _UserID
.Parameters.Add("@LDate", SqlDbType.DateTime).Value = dtUpdate
.Parameters.Add("@LUserID", SqlDbType.NVarChar, 20).Value = _UserID
.ExecuteNonQuery()
End With
XtraMessageBox.Show("Transaksi berhasil disimpan", "Simpan", MessageBoxButtons.OK, MessageBoxIcon.Information)
_SQLTransact.Commit()
Catch ex As Exception
__Simpan = False
_SQLTransact.Rollback()
MsgBox(ex.Message)
End Try
End Function
keyword : executenonquery requires the command to have a transaction...
Labels:
SQL Server,
VB.NET
0 komentar:
Posting Komentar