zoukankan      html  css  js  c++  java
  • C# ACCESS数据库链接

     private void button1_Click(object sender, EventArgs e)
            {          

    string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + @"E:mapSansMachine.mdb";

                OleDbConnection objConnection = new OleDbConnection(strConnection);  //建立连接  
                objConnection.Open();  //打开连接
                OleDbCommand sqlcmd = new OleDbCommand(@"select * from ParamFactValue where TestNo=10", objConnection);  //sql语句  
                OleDbDataReader reader = sqlcmd.ExecuteReader();              //执行查询 
          
                while (reader.Read())
                { //这个read调用很重要!不写的话运行时将提示找不到数据  
                    //age = (int)reader.getstring(0);   //取得字段的值  

                    textBox1.Text = reader["Name"].ToString();
                    textBox2.Text = reader["TheValue"].ToString();

                    
                }

                objConnection.Close();
                reader.Close();

  • 相关阅读:
    快速幂取模算法详解
    牛客网小白月赛5I区间(差分数组)
    多重背包模板
    hdu5791(DP)
    CodeForces
    最长上升子序列LIS(51nod1134)
    POJ1088(记忆搜索加dp)
    最长公共子序列LCS(POJ1458)
    Gym 100971J-Robots at Warehouse
    模板
  • 原文地址:https://www.cnblogs.com/rosesmall/p/5534843.html
Copyright © 2011-2022 走看看