Get & Set Regional Setting Menggunakan VB.NET

Posted On // Leave a Comment
yang harus di import

Imports System.Threading
Imports System.Globalization



get regional setting

Thread.CurrentThread.CurrentCulture.DisplayName.ToString

set regional setting ("id-ID" kode untuk Indonesia)

Thread.CurrentThread.CurrentCulture = New CultureInfo("id-ID", False)

Get System Directory on VB.NET

Posted On // Leave a Comment
Dim strSystemDir As String = Environment.GetEnvironmentVariable("SystemDrive")
Dim strSystemDir As String = Environment.SystemDirectory.Substring(0, 2)

kedua syntax di atas sama-sama akan menghasilkan system direktori windows.

Mencari Data Duplikat Menggunakan SQL

Posted On // Leave a Comment
Berikut adalah contoh query untuk menemukan duplikasi data pada suatu kolom,

SELECT email,
 COUNT(email) AS NumOccurrences
FROM users
GROUP BY email
HAVING ( COUNT(email) > 1 )

gunakan query berikut untuk menemukan data yang tidak memiliki duplikat


SELECT email
FROM users
GROUP BY email
HAVING ( COUNT(email) = 1 )

sumber : http://www.petefreitag.com

Concurrency violation: the UpdateCommand affected 0 of the expected 1 records.

Posted On // Leave a Comment
"Concurrency violation: the UpdateCommand affected 0 of the expected 1 records."

I got that message when i was try to update database when my DevExpress GridControl changed. Heres the wrong code:

Private Sub AdvBandedGridView1_RowUpdated(ByVal sender As System.Object, ByVal e As DevExpress.XtraGrid.Views.Base.RowObjectEventArgs) Handles AdvBandedGridView1.RowUpdated
        If AdvBandedGridView1.UpdateCurrentRow Then
            Try
                DAUniFix.Update(DsUniFix)
            Catch ex As Exception
                XtraMessageBox.Show(_LookAndFeel, ex.Message, Me.Text)
            End Try
        End If
    End Sub

To fix this error, make sure your table has primary key and simply add two line of syntax as shown below


Private Sub AdvBandedGridView1_RowUpdated(ByVal sender As System.Object, ByVal e As DevExpress.XtraGrid.Views.Base.RowObjectEventArgs) Handles AdvBandedGridView1.RowUpdated
        If AdvBandedGridView1.UpdateCurrentRow Then
            Try
                Me.Validate()
                Me.UniFixBindingSource.EndEdit()
                DAUniFix.Update(DsUniFix)
            Catch ex As Exception
                XtraMessageBox.Show(_LookAndFeel, ex.Message, Me.Text)
            End Try
        End If
    End Sub