FUNGSI SIMPAN DINAMIS PADA VB.NET

FUNGSI SIMPAN DINAMIS PADA VB.NET

Create: nadir3011 | Rabu, 05 November 2014 | 23:09:12 WITA | dibaca: 7043

ASSALAMUALAIKUM WR WB

SALAM LOGIKA 

 

Berikut ini hasil rangkuman yang sudah dipelajari, jadi buat teman-teman yang ingin membuat fungsi simpan secara dinamis dapat menggunakan contoh algoritma query dinamis simpan dalam visual basic.net

Untuk penjelasan dari sorce code fungsi simpan dinamis akan dijelaskan berupa komentar pada listingnya.

 

 

Imports System.Data.SqlClient

Imports MySql.Data.MySqlClient

Imports System.Data.OleDb

Imports AkiLL.pesan 'Class variabel pesan yang akan kita gunakan pada saat proses simpan dieksekusi

 

Public Class simpan

    Inherits GlobalVariabel

 

    Private Sub x()

        fieldku = simpan("nmtabelku", " ", "", "", "")

        QuerySimpanSql(fieldku(0), 0)

    End Sub

 

    Public Shared Sub QuerySimpanSql(ByRef sqlQuery As String, Optional ByRef pp As Byte = 1)

        Query = sqlQuery

        AksiSimpanSql(pp)

    End Sub

 

    Public Shared Sub QuerySimpanMySql(ByRef sqlQuery As String, Optional ByRef pp As Byte = 1)

        Query = sqlQuery

        AksiSimpanMySql(pp)

    End Sub

 

    Public Shared Sub QuerySimpanOleDb(ByRef sqlQuery As String, Optional ByRef pp As Byte = 1)

        Query = sqlQuery

        AksiSimpanOleDb(pp)

    End Sub

 

    Public Shared Sub AksiSimpanMySql(Optional ByRef angka As Byte = 1)

        If (angka = 1) Then

            Try

                connMySql.Open()

                cmdMySql = New MySqlCommand(Query, connMySql)

                cmdMySql.ExecuteNonQuery()

                TampilPesanSuksesSimpan()

            Catch ex As Exception

                TampilPesanTidakSuksesSimpan()

            Finally

                connMySql.Close()

            End Try

        ElseIf (angka = 0) Then

            Try

                connMySql.Open()

                cmdMySql = New MySqlCommand(Query, connMySql)

                cmd.ExecuteNonQuery()

            Catch ex As Exception

 

            Finally

                connMySql.Close()

            End Try

        End If

    End Sub

 

    Public Shared Sub AksiSimpanSql(Optional ByRef angka As Byte = 1)

        If (angka = 1) Then

            Try

                conn.Open()

                cmd = New SqlCommand(Query, conn)

                cmd.ExecuteNonQuery()

                TampilPesanSuksesSimpan()

            Catch ex As Exception

                TampilPesanTidakSuksesSimpan()

            Finally

                conn.Close()

            End Try

        ElseIf (angka = 0) Then

            Try

                conn.Open()

                cmd = New SqlCommand(Query, conn)

                cmd.ExecuteNonQuery()

            Catch ex As Exception

 

            Finally

                conn.Close()

            End Try

        End If

    End Sub

 

    Public Shared Sub AksiSimpanOleDb(Optional ByRef angka As Byte = 1)

        If (angka = 1) Then

            Try

                connOle.Open()'Peringtah untuk membuka koneksi pada database

                cmdOle = New OleDbCommand(Query, connOle) 'Perintah query yang akan di eksekusi setelah variabel query diberikan nilai

                cmdOle.ExecuteNonQuery()

                TampilPesanSuksesSimpan()'Sebuah class yang sudah dibuat dan telah di import pada bagian atas class ini

            Catch ex As Exception

                TampilPesanTidakSuksesSimpan()

            Finally

                connOle.Close()

            End Try

        ElseIf (angka = 0) Then

            Try

                connOle.Open()

                cmdOle = New OleDbCommand(Query, connOle)

                cmdOle.ExecuteNonQuery()

                'TampilPesanSuksesSimpan()

            Catch ex As Exception

                'TampilPesanTidakSuksesSimpan()

            Finally

                connOle.Close()

            End Try

        End If

    End Sub

 

    'Dibawah ini adalah fungsi dalam membuat listing query yang dijadikan string setelah di

    Public Shared Function simpan(ByVal nmtbl As String, ByVal ParamArray args() As Object) As String()

        Dim hasil(0) As String

        Dim hsl As String

        Dim s As Byte

        hsl = "insert into " + nmtbl + " values('"

 

        Dim i As Integer

        s = UBound(args) 'Ubound maksudnya menghitung jumlah index dalam variabel args()

        For i = 0 To UBound(args)

            If s <> i Then

                Try

                    hasil(0) = hasil(0) + args(i) + "','"

                Catch ex As Exception

                    hasil(0) = hasil(0) + args(i).ToString + "','"

                End Try

            Else

                Try

                    hasil(0) = hasil(0) + args(i) + "'"

                Catch ex As Exception

                    hasil(0) = hasil(0) + args(i).ToString + "'"

                End Try

            End If

        Next i

        hasil(0) = hsl + hasil(0) + ")"

        Return hasil

    End Function

End Class

 

Jadi, untuk kesimpulannya diatas proses penyimpanan kedalam database hanya bisa menggunakan database access, mysql, dan sql server.

Untuk penggunaannya tinggal disesuaikan sesuai kebutuhan. 

Sekian dulu materi kali ini sekian dan terima kasih.

 

WASSALAMUALAIKUM WR WB 



29 KOMENTAR

wsc biolo | 13 November 2014 || 09:58:18
" samgat bagus beritanya "
gula ampuh | 27 November 2014 || 10:11:55
" salam blogger "
jamu pelangsing | 27 November 2014 || 10:17:26
" sukses selalu "
pelangsing wsc biolo | 14 Maret 2015 || 09:38:02
" te ngartos abimah naon "
jamu pelangsing badan | 14 Maret 2015 || 09:38:59
" rumit sekali "
You TV Player Official | 09 Agustus 2017 || 13:03:30
" You are downloading You TV Player Latest APK v10.6 (122). Download You TV Player for PC and Run it on Windows 7/8/8.1/10 & Mac OS. It's very easy to install You TV Player iPhone App with the help of guide here. "
is mobro safe | 03 September 2017 || 20:36:10
" <a href="https://mobdropcwindows.co/is-mobdro-legal-and- safe/">is mobro safe</a>Mobdro is such kind of platform where you can stream all the videos "
Towelroot Apk Android 4.4.2 | 07 September 2017 || 20:31:33
" Thanks for this post!! it was great reading this article! i would like to know more!! keep posting!! This post was very informative and helpful!! Good quality content!! You can now get the best rooting app for all devices!! Towelroot Apk This is one of the most efficient and safe apk for rooting!! Also the best rated app for 2017! Check Out Towelroot "
dealer honda solo | 14 September 2017 || 15:27:43
" rumit "
Bootstrap Themes | 06 Oktober 2017 || 12:52:11
" Thank you for the Well detail article one of the best article i have ever read. "
Download Camscanner | 23 November 2017 || 12:50:46
" The CamScanner app for Android offers some rich and powerful features, even in the free version of the app. CamScanner app download install from 9apps. "
Happy New Year 2018 Messages | 30 November 2017 || 18:59:18
" On this amazing accident you can Free Download Happy New Year 2018 HD Wallpapers, Images from our website page. "
rolex uk | 07 Desember 2017 || 12:39:09
" Due to omega replicathe light-weight monocrystalline silicon that can not be oxidized "
hotstar movie app | 12 Desember 2017 || 14:15:40
" OTT Content Provider Hotstar App Downloads Hit 130 Million but Losses Rise to Rs 409 Crore. "
Aptoide | 16 Desember 2017 || 11:51:56
" Aptoide iOS is such an application which influences you to unwind as it gives all the exceptional application to free. "
Best motorcycle helmets | 19 Desember 2017 || 14:06:40
" learn how to choose best motorcycle helmets below Rather than giving you a strong rundown of the best cruiser cap, we isolated our rundown into various classes from Amazon.com like half face, open face, full face, double game and measured head protectors, which will enable you to locate the correct cap in light of the sort that you require. "
Klg | 13 Januari 2018 || 06:50:50
" thanks ypu infona "
imo for pc | 08 Februari 2018 || 17:47:07
" nice program "
imo for pc | 08 Februari 2018 || 17:47:19
" nice program "
josefrey | 03 Maret 2018 || 19:45:04
" The basic difference between a smartphone and that of the old keypad phones is the ability to download and install various applications. So eventually, applications play a crucial role in the working of devices. In this post, we are handing over such a fantastic app to our readers in the form of AppValley for android which is the heart of all the apps with the vast collection of apps within it. AppValley android option offers to download mods of apps and games without any charge. http://appvalleyappdownload.com/ "
MattMGordon | 05 Maret 2018 || 16:30:59
" For every Smartphone user apps play the vital role in enhancing the mobile experience, for every single work there is an app. So to expand the variety of different apps in your Smartphone lets jump in to try AppValley android app, it allows every android users to download various paid apps of play store for free and even those apps you will never find on any website or Appstore. AppValley apk android even offers tweaked and hacked apps with the help of these apps you can take advantage of all premium features and unlock all the expensive tools for free available at higher costs in-app-purchase. "
geometry dash | 20 Maret 2018 || 14:37:59
" Thank for your post. It's very helpful. By the way, follow my website to get tips about "
www.hotmail.com | 20 Maret 2018 || 17:16:10
" <a href="https://allmailinfo.com/www-hotmail-com-sign-up -sign-in-login/">outlook.live.com</a> "
www.hotmail.com | 20 Maret 2018 || 17:16:41
" <a href="https://allmailinfo.com/www-hotmail-com-sign-up -sign-in-login/">outlook.live.com</a> "
Joe Rubin | 30 Maret 2018 || 17:21:14
" We are presenting all the significant information about vRoot apk, vRoot software, vRoot free download, latest vRoot apk download, vRoot for android and vRoot download for your android device. "
shareit for pc filehippo | 18 April 2018 || 15:41:49
" shareit for pc filehippo ayou can now download shareit for windows "
Read More | 22 Mei 2018 || 12:00:15
" You just have to follow the simple procedure in order to download Read More for android. "
happy wheels | 03 Agustus 2018 || 11:58:32
" I have read through some similar topics! However, your post has given me a very special impression, unlike other posts. I hope you continue to have valuable articles like this or more to share with everyone! "
happy wheels | 03 Agustus 2018 || 11:58:45
" I have read through some similar topics! However, your post has given me a very special impression, unlike other posts. I hope you continue to have valuable articles like this or more to share with everyone! "



ISI KOMENTAR

NAMA

WEBSITE

KOMENTAR


Captcha Sepakbola
Apakah anda manusia?Lebih baik lagi kalau anda menyukai sepak bola
Sebutkan pemain sepak bola disamping:

Captcha Sepakbola by codingwear








  • $DCC = NEW XXI("Solidaritas","Loyalitas","Kualitas");
  • PELATIHAN KAMPUS
  • Pelatihan Komputer (DIGITAL SCHOOL)
  • Study Tour GoTv
  • IT FUN