码迷,mamicode.com
首页 > Web开发 > 详细

ADO.NET

时间:2015-07-13 20:13:05      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:

获取DataTable

DataTable dtTable = null;
using (SqlConnection connSelect = new SqlConnection(_connFirst))
{
    try
    {
        connSelect.Open();
        string strSql = "select BarcodeCompInfo.*,WorkOrder.ContractID from BarcodeCompInfo left join WorkOrder on BarcodeCompInfo.WorkOrderID=WorkOrder.WorkOrderID where BarcodeCompInfo.AID>=" + begin + " and BarcodeCompInfo.AID<" + end;
        SqlDataAdapter myDp = new SqlDataAdapter(strSql, connSelect);
        DataSet ds = new DataSet();
        myDp.Fill(ds);
        connSelect.Close();

        dtTable = ds.Tables[0];
    }
    catch { }
}

 

 

插入

using (SqlConnection connInsert = new SqlConnection(_connSecond))
{
      connInsert.Open();
      SqlCommand command = new SqlCommand(strSql, connInsert);
      command.CommandType = CommandType.Text;
      command.ExecuteNonQuery();
      connInsert.Close();
}

 

ADO.NET

标签:

原文地址:http://www.cnblogs.com/zhongxinWang/p/4643489.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!