Funciones de ejemplos visual basic mysql

Solo disponible en BuenasTareas
  • Páginas : 2 (267 palabras )
  • Descarga(s) : 0
  • Publicado : 6 de febrero de 2012
Leer documento completo
Vista previa del texto
FUNCIONES DE EJEMPLO PARA CONEXIONES BASE DE DATOS MYSQL CON VB

Option Explicit

Function RunSQl(ByVal sSQL As String, ByVal cServ As String, ByVal cBD As String, ByVal cUsua AsString, ByVal cClave As String)
Dim oCon As ADODB.Connection
Set oCon = CreateObject("ADODB.Connection")
oCon.ConnectionString = "Provider=MSDASQL.1;Persist SecurityInfo=False;Extended Properties=DSN=myodbc3-test;DESC=MySQL ODBC 3.51 TEST DSN;DATABASE=" & cBD & ";SERVER=" & cServ & ";UID=" & cUsua & ";PASSWORD=" & cClave& ";PORT=3306;OPTION=3;STMT=;"
oCon.Open
oCon.Execute sSQL
oCon.Close
End Function

Function SQLReturnRS(ByVal sSQL As String, ByVal cServ As String, ByVal cBD AsString, ByVal cUsua As String, ByVal cClave As String) As Recordset
Dim oCon As Connection
Set oCon = CreateObject("ADODB.Connection")
oCon.ConnectionString ="Provider=MSDASQL.1;Persist Security Info=False;Extended Properties=DSN=myodbc3-test;DESC=MySQL ODBC 3.51 TEST DSN;DATABASE=" & cBD & ";SERVER=" & cServ & ";UID=" & cUsua &";PASSWORD=" & cClave & ";PORT=3306;OPTION=3;STMT=;"
oCon.Open
Set SQLReturnRS = oCon.Execute(sSQL)
End Function
Public Function Conectar(ByVal cServ As String, ByVal cBDAs String, ByVal cUsua As String, ByVal cClave As String) As Boolean
Dim oCon As Connection
On Error GoTo Salir
Set oCon = CreateObject("ADODB.Connection")oCon.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;Extended Properties=DSN=myodbc3-test;DESC=MySQL ODBC 3.51 TEST DSN;DATABASE=" & cBD & ";SERVER=" & cServ &";UID=" & cUsua & ";PASSWORD=" & cClave & ";PORT=3306;OPTION=3;STMT=;"
oCon.Open
Conectar = True
Exit Function
Salir:
Conectar = False
End Function
tracking img