c# 链接mdb读写代码

OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+ tpml2); //Jet OLEDB:Database Password=
            OleDbCommand cmd = conn.CreateCommand();

            cmd.CommandText = "select * from ZD_0";
            conn.Open();
            OleDbDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                string bdcdyh = dr["不动产单元号"].ToString();
                if (bdcdyh == "")
                {
                    int result = 0;
                    bdcdyh = dr["宗地代码"].ToString() + "F9999" + dr["幢号"].ToString();
                    string id = dr["id"].ToString();
                    string sql = "update ZRZ set 不动产单元号='"+bdcdyh+"' where id=" + id;
                    OleDbCommand oleCmd = new OleDbCommand(sql, conn);
                    oleCmd.ExecuteNonQuery();
                }
            }

你可能感兴趣的:(C#,c#)