1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
Imports MySql.Data.MySqlClient
Imports System
Imports System.Globalization
Imports System.Threading
Imports System.Configuration
Public Class Form1
Dim MysqlConn As MySqlConnection
Dim COMMAND As MySqlCommand
Dim READER As MySqlDataReader
Dim dr As MySqlDataReader
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
MysqlConn = New MySqlConnection(ConfigurationManager.ConnectionStrings("xCollectibles.My.MySettings.xcollectiblesConnectionString").ToString)
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.Cursor = Cursors.WaitCursor
Try
MysqlConn.Close()
MysqlConn.Open()
MysqlConn = New MySqlConnection(ConfigurationManager.ConnectionStrings("xCollectibles.My.MySettings.xcollectiblesConnectionString").ToString)
COMMAND.CommandText = "INSERT INTO xcollectibles.maker (name, info) Values (@Value1, @Value2)"
COMMAND.Parameters.AddWithValue("@Value1", If(String.IsNullOrEmpty(TextBox2.Text), DBNull.Value, TextBox2.Text))
COMMAND.Parameters.AddWithValue("@Value2", If(String.IsNullOrEmpty(TextBox3.Text), DBNull.Value, TextBox3.Text))
READER = COMMAND.ExecuteReader
MessageBox.Show("Datos Guardados")
'Reinicio Plantilla
Controls.Clear()
InitializeComponent()
Form1_Load(Me, Nothing)
'Reinicio Plantilla
MysqlConn.Close()
'Catch ex As Exception
' MessageBox.Show(ex.Message)
Finally
MysqlConn.Dispose()
End Try
Me.Cursor = Cursors.Default
End Sub
End Class |
Partager