Using DataTable Mappings : SQL Server « ADO.Net « C# / CSharp Tutorial






using System;
using System.Data;
using System.Data.Common;
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);
  }
}








32.5.SQL Server
32.5.1.Creating SQL Connections
32.5.2.Using DataTable Mappings