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!
http://www.virustotal.com/file-scan/...7f4-1295505098
http://vscan.novirusthanks.org/file/...2LTMtNi16aXA=/