Ver Mensaje Individual
  #6 (permalink)  
Antiguo 09/07/2010, 08:29
Ka0stj
 
Fecha de Ingreso: febrero-2010
Ubicación: México
Mensajes: 738
Antigüedad: 15 años, 1 mes
Puntos: 37
Respuesta: como conectar VB.net con MYSQL

Código vb:
Ver original
  1. Dim objConn As New MySql.Data.MySqlClient.MySqlConnection
  2.  
  3.   Public Function StrConexion() As String
  4.         Try
  5.             Dim cn As New MySql.Data.MySqlClient.MySqlConnection
  6.             cn.ConnectionString = "server=localhost;userid=root;password=admin;database=BD;"
  7.  
  8.             Return cn.ConnectionString
  9.  
  10.         Catch ex As Exception
  11.             Throw ex
  12.         End Try
  13.     End Function
  14.  
  15. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  16.  
  17. objConn = New MySql.Data.MySqlClient.MySqlConnection(StrConexion)
  18.  
  19. Try
  20.  
  21. objConn.Open()
  22.  
  23. 'Funcionalidad
  24.  
  25. objConn.Close()
  26.  
  27. Catch ex As MySql.Data.MySqlClient.MySqlException
  28.   MessageBox.Show(ex.Message)
  29. End Try
  30.  
  31. End Sub