Using DataTable Mappings : SQL Server : ADO.Net C# Examples


C# Examples » ADO.Net » SQL Server »

 

Using DataTable Mappings









    
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);
    }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo ADO.Net
» SQL Server