Connect to DB using LINQ
Steps
1. Create the schema for your database.
Download the SQLMETAL tool and make the schema file for your database
SQL METAL Command to generate shcema:
<location>\SqlMetal.exe /server:serverName /database:databaseName /functions /sprocs
/language:cs /code:<location to="" generate="" schema="">\schemaFile.cs /namespace:nameSpaceName /pluralize</location></location>
For more options of the SQL metal please goto
http://msdn.microsoft.com/en-us/library/bb386987(v=VS.90).aspx[
^]
2. Once the Schema is generated, attach it to your project.
3. While your application on load, connect to database using connection string.
DatabaseName _db = new DatabaseName(@"Persist Security Info=False" +
";Integrated Security=" + _integratedSecurity +
";User ID=" + _userName +
";Initial Catalog=" + _dbIdentification +
";Data Source=" + _serverName +
";Password=" + _password);
4. Then you can use the '_db' object to access the database.
_db.Products.Single(a => a.Name == productName)