首页 > Web开发 > 详细

ADO.NET

时间:2015-07-13 20:10:52      阅读:245      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!