Looping pada SQL Server

Posted On // Leave a Comment


1) Example of WHILE Loop
DECLARE @intFlag INT
SET @intFlag = 1
WHILE (@intFlag <=5)
BEGIN
PRINT @intFlag
SET @intFlag = @intFlag + 1
END
GO

ResultSet:
1
2
3
4
5

2) Example of WHILE Loop with BREAK keyword
DECLARE @intFlag INT
SET @intFlag = 1
WHILE (@intFlag <=5)
BEGIN
PRINT @intFlag
SET @intFlag = @intFlag + 1
IF @intFlag = 4
BREAK;
END
GO

ResultSet:
1
2
3

3) Example of WHILE Loop with CONTINUE and BREAK keywords
DECLARE @intFlag INT
SET @intFlag = 1
WHILE (@intFlag <=5)
BEGIN
PRINT @intFlag
SET @intFlag = @intFlag + 1
CONTINUE;
IF @intFlag = 4 -- This will never executed
BREAK;
END
GO

ResultSet:
1
2
3
4
5

sumber : http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/

Import Facebook Event Ke Google Calendar

Posted On // Leave a Comment
Google Calendar adalah salah satu aplikasi yang menurut saya sangat berguna untuk produktifitas. Kita bisa mengatur semua jadwal & reminder agar tidak lupa. Kelebihan nya adalah google calendar ini bisa di synchronize ke berbagai macam device seprti iPhone, BlackBerry dan Android. Jadi saat Anda membuat jadwal di Google Calendar, secara otomatis jadwal tersebut akan di synchronize ke device yang Anda miliki.

Import & Synchronize Facebook Event Ke Google Calendar
seperti di google, Facebook pun memiliki fasilitas sama yang mirip seperti Google Calendar, yaitu Facebook Events (Acara). Berikut adalah cara untuk mensinkron kan events yang ada di Facebook:

  • Buka halaman facebook.
  • klik Aplikasi
  • klik Acara (Events)
  • di sebelah kanan, klik button kaca pembesar
  • Klik Expor Acara
  • setelah itu akan muncul url seperti berikut & copy url
    • webcal://www.facebook.com/ical/u.php?uid=12954*****&key=AQBrVwsRu*****Sb
  • buka calendar.google.com
  • Klik tombol Other Calendar > Add By Url > Masukan URL yang sebelumnya telah kita copy
  • Add Calendar
jika setelah add calendar muncul pesan error, reload halaman google calendar.

Penggunaan Stored Procedure dan Sql Data Adapter pada vb.net

Posted On // Leave a Comment
Dim conn As New SqlConnection(strConn)
Dim cmd As New SqlCommand("MyStoredProcedure", conn)
With cmd
    .CommandType = CommandType.StoredProcedure
    .Parameters.Add("@pdata", SqlDbType.VarChar, 100)
    .Parameters("@pdata").Value = "Whatever"
End With
Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds)

Registry Pada Visual Basic .NET

Posted On // Leave a Comment
Module

Public Sub ___RegistrySet(ByVal _strRegSubKey As String, _
                               ByVal _strRegValue As String)

        Dim _RegistryKey As RegistryKey
        _RegistryKey = Registry.LocalMachine

        Dim _RegistrySubKey As RegistryKey
        _RegistrySubKey = _RegistryKey.OpenSubKey("SOFTWARE\SMSAdv\Setting", True)
        If _RegistrySubKey Is Nothing Then
            _RegistrySubKey.CreateSubKey("SOFTWARE\SMSAdv\Setting")
        Else
            _RegistrySubKey.SetValue(_strRegSubKey, _strRegValue)
        End If

        _RegistryKey.Close()

    End Sub

    Public Function ___RegistryGet(ByVal _strRegValue As String) As String

        Dim _RegistryKey As RegistryKey
        _RegistryKey = Registry.LocalMachine

        Dim _RegistrySubKey As RegistryKey
        _RegistrySubKey = _RegistryKey.OpenSubKey("SOFTWARE\SMSAdv\Setting", True)
        Return _RegistrySubKey.GetValue(_strRegValue)

    End Function

'GET REGISTRY VALUE
CBEModem.EditValue = ___RegistryGet("Modem")

'SET REGISTRY
___RegistrySet("Database", TEDatabase.EditValue.ToString.Trim)