como conectar una base de datos desde sql 2008 a visual studio 2005?

Imports System.Data

Imports System.Data.Odbc

Module Module1

Public x As String

Public conexion As OleDbConnection

Public strConexion As String

Public comando As OleDbCommand

Public strComando As String

Public lector As OleDbDataReader

Public usuario As String

Public Sub Conectar()

Try

strConexion = ("Provider=SQLOLEDB;Initial Catalog=pubs; Data Source=x ;Integrated Security=SSPI;Initial Catalog=GYM_Data")

conexion = New OleDbConnection(strConexion)

conexion.Open()

MsgBox(" Conectado correctamente")

Catch ex As Exception

MsgBox(" Error en la conexion", MsgBoxStyle.Critical, "Lo sentimos")

MsgBox(ex.Message)

End Try

End Sub

'Public conectar As New OleDbConnection("Provider=SQLoledb.1;User id=sa;initial catalog=GYM;data source=(Data Source=.\SQLEXPRESS;AttachDbFilename=E:\usb\Programacion Visual\TeRcEr PaRcIaL\Proyecto GYM\Proyecto_Gym\Proyecto_Gym\GYM_Data.MDF;)")

End Module

quiero susituir la parte de sousrse por una conecion local

Comments

Sign In or Register to comment.