DataTableMapping.ColumnMappings.Add : DataTableMapping « System.Data.Common « C# / C Sharp by API






DataTableMapping.ColumnMappings.Add

 


using System;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;


    public class UsingDataTableMappings
    {
        static void Main(string[] args)
        {
            SqlConnection SConn = new SqlConnection("Data Source=(local); Initial Catalog = CaseManager; Integrated Security=true");
            SqlDataAdapter da = new SqlDataAdapter("SELECT ID, Contact, Email FROM CaseInfo", SConn);
            DataSet ds = new DataSet();
            DataTableMapping custMap = da.TableMappings.Add("CaseInfo", "MyDatabase");
            custMap.ColumnMappings.Add("ID", "CaseNumber");
            custMap.ColumnMappings.Add("Contact", "MyContact");
            custMap.ColumnMappings.Add("Email", "Email Address");
            da.Fill(ds);
        }
    }

   
  








Related examples in the same category