Results 1 to 9 of 9
  1. #1
    mnpeepno2's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    In a barren wasteland
    Posts
    906
    Reputation
    10
    Thanks
    81

    [Visual Basic]Edit Tables in mySQL

    Velcomen to editing tbls in mySQL!

    First import the mysql connector (download and extract below)
    Then Add the reference: Projekt => Add Reference => Browse => Path of mySQL.Data.dll

    Now we insert teh imports:
    Code:
    Imports System
    Imports System.Data
    Imports System.Windows.Forms
    Imports MySql.Data.MySqlClient
    Add some dims(under form1):
    Code:
    Dim conn As MySqlConnection
        Dim data As DataTable
        Dim da As MySqlDataAdapter
        Dim cb As MySqlCommandBuilder
    Now we start!
    But really, lets start... (It says "Friday!!!!!!!!! Burn the shrimp, burn it)

    Add 5 Textboxes & 1 Buten!

    Textbox1 : Server URL; URL to connect to the server
    Textbox2 : Database Name: Name of the Database
    Textbox3 : Database Table: (Just to be more precise, cause I don't like selectin my tables!)
    Textbox4 : Database Username: Username used to connect.
    Textbox5 : Database Password: Password used to connect.
    Button1 : Button that will handle the connection.

    If you want, you can make textbox5 have a password char of "•"

    Under Button1:

    Code:
    'Disable Buttens!
    TextBox1.Enabled = False
            TextBox2.Enabled = False
            TextBox3.Enabled = False
            TextBox4.Enabled = False
            TextBox5.Enabled = False
            Button1.Enabled = False
            If Not conn Is Nothing Then conn.Close()
            'Server Info
            Dim connStr As String
            connStr = String.Format("server=" & TextBox1.Text & ";user id=" & TextBox4.Text & "; password=" & TextBox5.Text & "; database=" & TextBox2.Text & "; pooling=false", TextBox1.Text, TextBox4.Text, TextBox5.Text)
    
            Try
                conn = New MySqlConnection(connStr)
                conn.Open()
                'Connection Success
                ShowTbl()
            Catch ex As MySqlException
                'Connection Failed, redo.
                MessageBox.Show("Error connecting to the server: " + ex.Message)
                TextBox1.Enabled = True
                TextBox2.Enabled = True
                TextBox3.Enabled = True
                TextBox4.Enabled = True
                TextBox5.Enabled = True
                Button1.Enabled = True
            End Try
    So lets make a new function for ShowTbl()!

    Code:
    Public Sub ShowTbl()
    
    End Sub
    Add a DataGridView called DataGridView1 -.-

    Add a butten that will save the database called button2


    Yay! or not...


    So teh Code under it (Sub ShowTbl()):
    Code:
    data = New DataTable
            da = New MySqlDataAdapter("SELECT * FROM " + TextBox3.Text, conn)
            cb = New MySqlCommandBuilder(da)
            da.Fill(data)
            DataGridView1.DataSource = data
            data.AcceptChanges()
            TextBox6.Enabled = True
            Button2.Enabled = True
        End Sub
    Now For the Final Code! (Butten2):
    Code:
    Try
                Dim changes As DataTable = data.GetChanges()
                da.Update(changes)
                data.AcceptChanges()
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try
    You will most likely get an error after trying to edit your database, ignore it and reclick the button untill it goes away.

    DO NOT DELETE ROWS IT WILL NOT WORK!

    Another tutorial will be added about removing rows sometime 2moro.

    Tank Joo!
    https://www.virustotal.com/file-scan/...7f4-1295505098
    https://vscan.novirusthanks.org/file/...2LTMtNi16aXA=/
    Last edited by mnpeepno2; 01-20-2011 at 12:28 AM.

  2. The Following 2 Users Say Thank You to mnpeepno2 For This Useful Post:

    Hassan (01-20-2011),Jason (01-20-2011)

  3. #2
    Lolland's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Location
    Lolland!
    Posts
    3,160
    Reputation
    49
    Thanks
    868
    My Mood
    Inspired
    Virus scan.

  4. #3
    mnpeepno2's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    In a barren wasteland
    Posts
    906
    Reputation
    10
    Thanks
    81
    Last edited by mnpeepno2; 01-20-2011 at 12:28 AM.

  5. #4
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,705
    Reputation
    918
    Thanks
    7,654
    My Mood
    Mellow
    TL;DR just yet, I'll go through it properly tonight. Looks good from what I did read though.

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  6. #5
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,765
    Reputation
    495
    Thanks
    2,114
    My Mood
    Dead
    Good Job Son.

  7. #6
    mnpeepno2's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    In a barren wasteland
    Posts
    906
    Reputation
    10
    Thanks
    81
    Quote Originally Posted by Hassan View Post
    Good Job Son.
    Thanks Daddy!


    Quote Originally Posted by Jason View Post
    TL;DR just yet, I'll go through it properly tonight. Looks good from what I did read though.
    uhh, ok.

  8. #7
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,705
    Reputation
    918
    Thanks
    7,654
    My Mood
    Mellow
    Okay, most of it seems pretty good! Of course there are ways that it could be improved slightly, but that's the case with 90% of code.

    Oh yeah

    Code:
    Imports System
    Imports System.Data
    Imports System.Windows.Forms


    All of these namespaces are imported by default, so no need to manually type them out.

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  9. #8
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,324
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    Moved to Tutorials section. Should be here. Visual Basic section is not for tutorials, it is for Closed application releases and questions.

    Open Source Applications goto Open source, Snippets to snippets vault, tuts to tutorial section and tut requests to tut request section.

    There is a reason for the sub sections, use them please & thank you.


     


     


     



    The Most complete application MPGH will ever offer - 68%




  10. #9
    mnpeepno2's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    In a barren wasteland
    Posts
    906
    Reputation
    10
    Thanks
    81
    Quote Originally Posted by Jason View Post
    Okay, most of it seems pretty good! Of course there are ways that it could be improved slightly, but that's the case with 90% of code.

    Oh yeah

    Code:
    Imports System
    Imports System.Data
    Imports System.Windows.Forms


    All of these namespaces are imported by default, so no need to manually type them out.
    Just felt like adding them to the imports list.