Материал из .Net Framework эксперт
Creating SQL Connections
using System;
using System.Data.SqlClient;
class MainClass
{
static void Main(string[] args)
{
SqlConnection MyConnection = new SqlConnection("Data Source=(local); Initial Catalog = MyDatabase; User ID=sa;Password=");
MyConnection.Open();
}
}
Using DataTable Mappings
using System;
using System.Data;
using System.Data.rumon;
using System.Data.SqlClient;
class MainClass
{
static void Main(string[] args)
{
SqlConnection SConn = new SqlConnection("Data Source=(local); Initial Catalog = CaseManager; Integrated Security=true");
SqlDataAdapter da = new SqlDataAdapter("SELECT ID, FirstName, LastName FROM Employee", SConn);
DataSet ds = new DataSet();
DataTableMapping custMap = da.TableMappings.Add("Employee", "MyDatabase");
custMap.ColumnMappings.Add("ID", "Number");
custMap.ColumnMappings.Add("FirstName", "first name");
custMap.ColumnMappings.Add("LastName", "last name");
da.Fill(ds);
}
}