CONEXION C# - SQLServer

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.SqlClient; using System.Data; namespace ProyectoN1 { class DBConexion { private SqlConnection conexionDB; private string stringConexion; public DBConexion() { stringConexion = @"Data Source = NOMBRE-PC; Initial Catalog = NOMBREBD; User Id = sa; Password = 123;"; conexionDB = null; } public string StringConexion { set { stringConexion = value; } get { return stringConexion; } } public SqlConnection conectar() { conexionDB = new SqlConnection(StringConexion); try { conexionDB.Open(); } catch(SqlException error){ throw new Exception(error.Message); } return conexionDB; } } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.