My SQL
My SQL
vb 1
Imports System.Data.SqlClient
Imports System.Data
Imports System.Text.RegularExpressions
Public Sub New(ByVal pServer As String, ByVal pDatabase As String, ByVal pUserId As
String, _
ByVal pPassword As String)
strCnn.DataSource = pServer
strCnn.InitialCatalog = pDatabase
strCnn.UserID = pUserId
strCnn.Password = pPassword
strCnn.IntegratedSecurity = (pUserId.Trim() = "")
cnn = New SqlConnection(strCnn.ConnectionString)
AddHandler cnn.InfoMessage, AddressOf cnn_InfoMessage
End Sub
Public Function ParseScriptToCommands(ByVal script As String) As String()
Dim commands() As String
commands = Regex.Split(script, _
"GO\r\n", _
RegexOptions.IgnoreCase)
Return commands
End Function
Public Sub GetData(ByVal selectCommand As String, ByVal tabla As String)
Try
' cadena de conexion
Dim connectionString As String = cnn.ConnectionString
' Crear un command builder para generar los commandos SQL update, insert, y
' delete basado en selectCommand. These are used to
' update the database.
Dim commandBuilder As New SqlCommandBuilder(Me.dataAdapter)
Catch ex As SqlException
MessageBox.Show("To run this example, replace the value of the " + _
"connectionString variable with a connection string that is " + _
"valid for your system.")
End Try
End Sub
Public Sub LlenarDataGridView(ByVal DataGridView1 As DataGridView, ByVal comando As
String, ByVal TablaDelComando As String)
With DataGridView1
C:\Users\Juan Nava\Desktop\proyectos\EXCELTOSQLCSHARP\EXCELTOSQLVB\EXCELTOSQLVB\MySQL.vb 2
' alternar color de filas
.AlternatingRowsDefaultCellStyle.BackColor = Color.FloralWhite
.DefaultCellStyle.BackColor = Color.Beige
' Establecer el origen de datos para el DataGridview
.DataSource = bindingSource1
' Resize the DataGridView columns to fit the newly loaded content.
.AutoResizeColumns( _
DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader)
End With
End Sub
mMessages = e.Message
End Sub