首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

新手 C#链接access哪里出错了

2013-08-04 
新手求助 C#链接access哪里出错了点击按钮后和卡死一样没反应,代码如下private void Button_Click_1(objec

新手求助 C#链接access哪里出错了
点击按钮后和卡死一样没反应,代码如下


private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            string dir = Directory.GetCurrentDirectory();
            string strcon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dir + "\\db.mdb";
            using (OleDbConnection con = new OleDbConnection(strcon))
            {
                if (con.State != ConnectionState.Open)
                {
                    con.Open();
                }
                
              

              DataSet ds = new DataSet();
              OleDbDataAdapter oda = new OleDbDataAdapter("select * from userinfo",con);
              oda.Fill(ds);
              DataTable table = ds.Tables[0];
              DataRowCollection rows=table.Rows;
              for(int i=0;i<rows.Count;i++){
                  DataRow row = rows[i];
                  string username = (string)row["username"];
                  MessageBox.Show(username);
              }
            }
        }


[解决办法]
http://blog.csdn.net/xianfajushi/article/details/8568304

热点排行