CLR: .Net / Mono / Boo / Otros CLR > VB .NET
conexion en visual .net
(1/1)
happypeace31:
holas a todos!!
Necesito saber como conectar una base de SQL en visual .net pero a traves del codigo
Le agradesco su ayuda :P
Espero me puedan ayudar gracias :beer:
malavida:
Espero te sirva.
Imports System.Data.SqlClient
Private CN As SqlConnection
Private DA As New SqlDataAdapter
' Con esto te conectas
Private Function Conectar(ByVal DA As SqlDataAdapter) As SqlDataAdapter
'Crear conexión
CN = New SqlConnection
Try
CN.ConnectionString = "Server=(local);" & "Database=BlackBox;uid=sa;pwd=sa;Integrated Security=SSPI;"
Catch ex As ArgumentException
MsgBox("Error:" & vbCrLf & "ConnectionString", MsgBoxStyle.Critical)
End Try
DA = New SqlDataAdapter
Return DA
End Function
'Una funcion para que ocupes la coneccion
Public Function Proveedor_Tabla() As DataSet
Conectar(DA)
DA.SelectCommand = New SqlCommand
DA.SelectCommand.Connection = CN
DA.SelectCommand.CommandText = "sp_TablaProveedores"
DA.SelectCommand.CommandType = CommandType.StoredProcedure
DS = New DataSet
DA.Fill(DS, "Proveedores")
DT = DS.Tables("Proveedores")
Return DS
End Function
happypeace31:
gracias por tu aporte me fue de gran ayuda :beer:
Navegación
Ir a la versión completa