主营业务:网站制作 网站优化 小程序制作 石家庄网站制作网站建设有限公司欢迎您!
石家庄闪云网络科技有限公司
客服热线15383239821
如何让自己的网站更有质量?

C#中创建Access库和建立表

发布时间:2010/7/24 17:17:25

/// <summary>
  /// 创建一个Access数据库对象.
  /// </summary>
  private void BulidAccess()
  {
   try
   {
    ADOX.CatalogClass Cat = new ADOX.CatalogClass();
    string DataBaseName=this.BuildName()+".mdb";
 
    this.DesDataBase+=DataBaseName;

    CreateText="Provider=Microsoft.Jet.OLEDB.4.0;" +
     "Data Source=" + this.DesDataBase + ";" +
     "Jet OLEDB:Engine Type=5";

    Cat.Create(CreateText);
   }
   catch(Exception e)
   {
    MessageBox.Show(e.Message.ToString(),"消息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
   }
   
  }

  /// <summary>
  /// 在新创建的数据库中创建表
  /// </summary>
  private void BuildTable()
  {
   try
   {
    this.OleCnnDes = new OleDbConnection(this.CreateText);
    this.OleCnnDes.Open();

    string SqlCreeate="Create table data(TestTime time,RunTime integer,HPV integer,DHPV integer,RPV integer,DRPV integer,LPV integer,DLPV integer)";

    OleDbCommand OleCmm=new OleDbCommand(SqlCreeate,this.OleCnnDes);
    OleCmm.ExecuteNonQuery();

   }
   catch(Exception e)
   {
    MessageBox.Show(e.Message.ToString(),"消息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
   }
   
  }
 

下一篇: 电脑开机鸣叫

相关新闻推荐

在线客服 : 服务热线:15383239821 电子邮箱: 27535611@qq.com

公司地址:石家庄市新华区九中街江西大厦4062

备案号:冀ICP备2022000585号-4