打印本文 打印本文 关闭窗口 关闭窗口
[我的ASP.net学习历程]数据库操作之(二)
作者:武汉SEO闵涛  文章来源:敏韬网  点击数701  更新时间:2009/4/23 10:44:30  文章录入:mintao  责任编辑:mintao

  private void Page_Load(object sender, System.EventArgs e)
  {
   string dbPath = @"Data\dbTest.mdb";
   string db = Server.MapPath(dbPath);
   string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + db;
   //string strSQL = "SELECT * FROM Customers";
   //string strSQL = "INSERT INTO Customers(CustomerID) VALUES (''''QQQQQ'''')";
   //string strSQL = @"UPDATE Customers SET CustomerID=''''PPPPP'''',Address=''''64651546'''' WHERE id=11";
   //string strSQL = @"DELETE FROM Customers WHERE id = 11";

   OleDbConnection conn = new OleDbConnection(connectionString);
   OleDbCommand cmd = new OleDbCommand(strSQL,conn);

   cmd.Connection.Open();
   cmd.ExecuteReader();
   conn.Close();

  }

打印本文 打印本文 关闭窗口 关闭窗口