tman43
asked on
How to fill empty cells of one Microsoft Access database using C#
I have a Microsoft Access database with columns MTRS, Lat_Y, and Lon_X filled with data all cells, 680,000 rows. I have a second similar Access database with data for MTRS but empty cells for Lat_Y, and Lon_X, 1600 rows. How do I fill the Lat_Y and Lon_X cells in the second smaller database for matching values of MTRS? I typically use OleDbConnection in C# to manipulate Access databases. I am weak on Access queries. I also have ArcGIS and QGIS but have limited experience with these.
Thanks,
Tim Sprout
Thanks,
Tim Sprout
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
//create ValuePair structure
struct ValuePair
{
public string Lat_Y;
public string Lon_X;
}
//create dictionary using ValuePair structure
Dictionary<string, ValuePair> dictionary = new Dictionary<string, ValuePair>();
//read large parent database that has all cells filled and load dictionary
private void btnDictionaryTest_Click(ob
{
string strConn = "Provider=Microsoft.Jet.OL
using (OleDbConnection connection = new OleDbConnection(strConn))
{
string strOleDb = "Select MTRS, Latitude, Longitude from tblRowMap";
OleDbCommand command = new OleDbCommand(strOleDb, connection);
connection.Open();
OleDbDataReader reader = command.ExecuteReader();
while (reader.Read())
{
string mTRS = reader.GetString(0);
string lat_Y = reader.GetValue(1).ToStrin
string lon_X = reader.GetValue(2).ToStrin
dictionary.Add(mTRS, new ValuePair { Lat_Y = lat_Y, Lon_X = lon_X });
}
reader.Close();
}
//read smaller child database that has empty cells that need filling (I used a DataGridView) and
//retrieve values for these keys
if (dictionary.ContainsKey(mT
{
string latGrid2 = dictionary[mtrsGrid2].Lat_
string lonGrid2 = dictionary[mtrsGrid2].Lon_
}
//INSERT these and other required fields into third empty database