2014年9月2日 星期二

using DataAdapter to DataTable

string cs = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

//1.SqlConnection
using (SqlConnection cn = new SqlConnection(cs))
{
    //2.SqlCommand
    using (SqlCommand cmd = new SqlCommand(sqlCMD, cn))
    {
        //3.SqlDataAdapter
        using (SqlDataAdapter da = new SqlDataAdapter(cmd))
        {
            //4.DataSet or DataTable            //Fill
            //===========================================
        }  
    }
}

沒有留言:

張貼留言