数据库

//数据库连接

            SqlConnectionobjSqlConnection = newSqlConnection("server=127.0.0.1;uid=sa;pwd=1;database=mysql");

            objSqlConnection.Open();

          //  MessageBox.Show("数据库连接成功","好"); 

            //数据库添加 CMD 对象执行插入语句

            //stringInsert = "insert into sticalleakage(plantname,boiler,faulttime,leakagelocation,leakagereason) values('";

 

            //Insert+= "333" + "',";

            //Insert+= "'" + "222" + "',";

            //Insert+= "'" + "2011-06-01"+ "',";

            //Insert +="'" + "222" + "',";

 

            //Insert+= "'" + "222" + "')";

 

            //SqlCommandsqlcom = new SqlCommand(Insert, objSqlConnection);

            //sqlcom.ExecuteNonQuery();

           //数据库的修改代码:和插入操作相同

            //stringupdate = "update   sticalleakage setplantname=4 where id=3 ";

            //SqlCommandsqlcom = new SqlCommand(update, objSqlConnection);

            //sqlcom.ExecuteNonQuery();

 

            //删除呢也一样

 

            //stringdelet = "delete from   sticalleakagewhere id=3 ";

            //SqlCommandsqlcom = new SqlCommand(delet, objSqlConnection);

            //sqlcom.ExecuteNonQuery();

            //查询

            //stringsql = "select boiler from  sticalleakage ";

            //SqlCommandsqlcom = new SqlCommand(sql, objSqlConnection);

            //SqlDataReaderdatareader = sqlcom.ExecuteReader();

            //while(datareader.Read())

            //{

            //   MessageBox.Show((string)datareader["boiler"], "好"); 

           

            //}

            //datareader.Close();

 

            //dataset的用法

            //SqlConnectionthisConnection = newSqlConnection(@"server=192.168.1.183;database=energy_cts;uid=sa;pwd=1");

 

            //SqlDataAdapterthisAdapter = new SqlDataAdapter("select * from Controltime",thisConnection);

            //SqlCommandBuilderthisBuilder = new SqlCommandBuilder(thisAdapter);

            //DataSetthisDataSet = new DataSet();

            //thisAdapter.Fill(thisDataSet,"Controltime");

  stringsRouter = "~/db/db1.mdb";

 

      

        //获得当前Access数据库在服务器端的绝对路径

        stringstrCon = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = " + System.Web.HttpContext.Current.Server.MapPath(sRouter);

    

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值