here is my mybb_mysql_query browser
code:
whats needed
1 textbox
1 gridview
1 button
Imports MySql.Data.MySqlClient
Imports System
Imports System.Security.Cryptography
Imports System.Text
Public Class Form1
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Dim g As Graphics = e.Graphics
Dim pen As New Pen(Color.Red, 4.0)
Dim txtBox As Control
For Each txtBox In Me.Controls
If TypeOf (txtBox) Is TextBox Then
g.DrawRectangle(pen, New Rectangle(txtBox.Location, _
txtBox.Size))
End If
Next
pen.Dispose()
End Sub
'Represents an SQL statement or stored procedure to execute against a data source.
Dim cmd As New MySqlCommand
Dim da As New MySqlDataAdapter
Public total As Integer
Dim publictable As New DataTable
'declare conn as connection and it will now a new connection because
'it is equal to Getconnection Function
Dim con As MySqlConnection = jokenconn()
Public Function jokenconn() As MySqlConnection
Return New MySqlConnection("server=server_ipaddress;user id=usernamehere; password=your-password-here;database=dbname")
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim publictable As New DataTable
Dim sql As String
sql = TextBox1.Text
Try
'bind the connection and query
With cmd
.Connection = con
.CommandText = sql
End With
'Gets or sets a Transact-SQL statement or stored procedure used to select records in the data source.
da.SelectCommand = cmd
da.Fill(publictable)
'get the datasource from publictable and passed to datagridview
DataGridView1.DataSource = publictable
'dispose the dataadapter
da.Dispose()
Catch ex As Exception
MsgBox(ex.Message)
End Try
con.Close()
da.Dispose()
End Sub
Public Overrides Property AutoSize As Boolean
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
TextBox1.BorderStyle = BorderStyle.None
DataGridView1.BorderStyle = BorderStyle.None
TextBox1.Text = "select * from mybb_users"
Button1.PerformClick()
Me.WindowState = FormWindowState.Maximized
DataGridView1.GridColor = Color.BlueViolet
TextBox1.AutoSize = True
End Sub
End Class
sql browser images:
(This post was last modified: 07-22-2017, 04:06 AM by viruss.) code:
whats needed
1 textbox
1 gridview
1 button
Imports MySql.Data.MySqlClient
Imports System
Imports System.Security.Cryptography
Imports System.Text
Public Class Form1
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Dim g As Graphics = e.Graphics
Dim pen As New Pen(Color.Red, 4.0)
Dim txtBox As Control
For Each txtBox In Me.Controls
If TypeOf (txtBox) Is TextBox Then
g.DrawRectangle(pen, New Rectangle(txtBox.Location, _
txtBox.Size))
End If
Next
pen.Dispose()
End Sub
'Represents an SQL statement or stored procedure to execute against a data source.
Dim cmd As New MySqlCommand
Dim da As New MySqlDataAdapter
Public total As Integer
Dim publictable As New DataTable
'declare conn as connection and it will now a new connection because
'it is equal to Getconnection Function
Dim con As MySqlConnection = jokenconn()
Public Function jokenconn() As MySqlConnection
Return New MySqlConnection("server=server_ipaddress;user id=usernamehere; password=your-password-here;database=dbname")
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim publictable As New DataTable
Dim sql As String
sql = TextBox1.Text
Try
'bind the connection and query
With cmd
.Connection = con
.CommandText = sql
End With
'Gets or sets a Transact-SQL statement or stored procedure used to select records in the data source.
da.SelectCommand = cmd
da.Fill(publictable)
'get the datasource from publictable and passed to datagridview
DataGridView1.DataSource = publictable
'dispose the dataadapter
da.Dispose()
Catch ex As Exception
MsgBox(ex.Message)
End Try
con.Close()
da.Dispose()
End Sub
Public Overrides Property AutoSize As Boolean
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
TextBox1.BorderStyle = BorderStyle.None
DataGridView1.BorderStyle = BorderStyle.None
TextBox1.Text = "select * from mybb_users"
Button1.PerformClick()
Me.WindowState = FormWindowState.Maximized
DataGridView1.GridColor = Color.BlueViolet
TextBox1.AutoSize = True
End Sub
End Class
sql browser images: