String Conexión a Sql Server 2008
Option 1 :
Data Source=yourSQLServer; Initial Catalog=yourDB; User Id=yourUserName; Password=yourPwd;
SqlConnection Example :1.SqlConnection theSqlServer = new SqlConnection("Data Source=SQLDevelopment; Initial Catalog=SQL2008; User Id=sql2008; Password=######;");
2.SqlCommand theSqlCommand = new SqlCommand("SELECT * FROM[dbo].[Users]", theSqlServer);
Option 2 :
Server=yourServer;Database=yourDB;User ID=yourUserName;Password=yourPwd;Trusted_Connection=False;
SqlConnection Example :
1.SqlConnectiontheSqlServer = new SqlConnection("Server=SQLDevelopment; Database=SQL2008; User ID=sql2008; Password=######; Trusted_Connection=False;");
2.SqlCommand theSqlCommand = new SqlCommand("SELECT * FROM[dbo].[Accounts]", theSqlServer);
Trusted Connection (Windows Authentication)
Option 1 :
Data Source=yourSQLServer; Initial Catalog=yourDB; Integrated Security=SSPI;
SqlConnection Example:
1.SqlConnection theSqlServer = new SqlConnection("Data Source=SQLDevelopment; Initial Catalog=SQL2008; Integrated Security=SSPI;");
2.SqlCommand theSqlCommand = new SqlCommand("SELECT * FROM[dbo].[Emplpoyees]", theSqlServer);
Option 2 :
Server=yourSQLServer; Database=yourDB; Trusted_Connection=True;
SqlConnection Example :
1.SqlConnection theSqlServer = new SqlConnection("Server=SQLDevelopment; Database=SQL2008; Trusted_Connection=True");
2.SqlCommand theSqlCommand = new SqlCommand("SELECT * FROM [dbo].[Students]", theSqlServer);
Connecting to the Local SQLServer – Standard Security
Option 1 :
Data Source=(local); Initial Catalog=yourDB; User Id=yourUserName; Password=yourPwd;
SqlConnection Example :
1.SqlConnection theSqlServer = newSqlConnection("Data Source=(local); Initial Catalog=SQL2008; User Id=sql2008; Password=######;");
2.SqlCommand theSqlCommand = new SqlCommand("SELECT * FROM [dbo].[Companies]", theSqlServer);
Option...
Regístrate para leer el documento completo.