SqlDataAdapter.TableMappings.Add : SqlDataAdapter « System.Data.SqlClient « C# / C Sharp by API






SqlDataAdapter.TableMappings.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

1.new SqlDataAdapter
2.SqlDataAdapter.Fill
3.SqlDataAdapter.DeleteCommand
4.SqlDataAdapter.InsertCommand
5.SqlDataAdapter.RowUpdated
6.SqlDataAdapter.RowUpdating
7.SqlDataAdapter.SelectCommand
8.SqlDataAdapter.SelectCommand.Parameters.Add
9.SqlDataAdapter.TableMappings
10.SqlDataAdapter.Update
11.SqlDataAdapter.UpdateCommand