函数conectar a BD SQL Server(sqlconection)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了函数conectar a BD SQL Server(sqlconection)相关的知识,希望对你有一定的参考价值。
Conexión a base de datos con los parametros que llega del contructor
Imports System Imports System.IO Imports System.Text Imports System.Data Imports System.Data.SqlClient Public Class DBSQLServer #Region "Properties" Private con As New SqlConnection Private cmd As New SqlCommand Private reader As SqlDataReader Private da As SqlDataAdapter Public Property StringConnection As String = "" Public Property Host() As String Public Property DBName() As String Public Property User() As String Public Property Pass() As String Public Property Port() As String = 3306 #End Region #Region "Constructores" Public Sub New(ByVal host As String, ByVal user As String, ByVal pass As String, ByVal DBName As String, ByVal Port As String) Me.Host = host Me.User = user Me.Pass = pass Me.DBName = DBName Me.Port = Port End Sub Public Sub New(ByVal host As String, ByVal user As String, ByVal pass As String, ByVal DBName As String) Me.Host = host Me.User = user Me.Pass = pass Me.DBName = DBName End Sub Public Sub New(ByVal strConnection As String) Me.StringConnection = strConnection End Sub #End Region #Region "Functions" ''' <summary> ''' conexion a la base de datos segun los parametros de constructor. ''' </summary> ''' <returns></returns> ''' <remarks></remarks> Private Function conecctedDB() As SqlConnection Try Me.con = New SqlConnection(Me.StringConnection) Else Me.con = New SqlConnection(String.Format("Data Source={0}; Integrated Security=False; Id={1}; Password={2}; Catalog={3};", Me.Host, Me.User, Me.Pass, Me.DBName)) End If Me.con.Open() Catch ex As SqlException Throw New System.Exception("Error de conexion a la basde de datos: (conectarBase)", ex) End Try Return Me.con End Function #End Region End Class
以上是关于函数conectar a BD SQL Server(sqlconection)的主要内容,如果未能解决你的问题,请参考以下文章
红色与公共汽车建筑联合会(Conectar a unidad de red y buscar archivos)
我想要把sql serve2000的mdf ldf文件升级到能在sql2012中用 求大神帮忙转换
windows 2012服务器,sql serve 20112怎么开通1433端口