using System;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Data.Common;
using System.Windows.Forms;
class MainClass
{
static void Main(string[] args)
{
string ConnectionString ="server=(local)\\SQLEXPRESS;database=MyDatabase;Integrated Security=SSPI;";
SqlConnection conn = new SqlConnection(ConnectionString);
conn.Open();
try
{
DataTableMapping myMapping = new DataTableMapping("Employee", "mapEmployee");
SqlDataAdapter adapter = new SqlDataAdapter("Select * From Employee", conn);
adapter.TableMappings.Add(myMapping);
DataSet ds = new DataSet();
adapter.Fill(ds, "mapEmployee");
Console.WriteLine(ds.Tables[0].ToString());
}
catch(SqlException ex)
{
Console.WriteLine(ex.Message.ToString());
}
}
}
|