public void FillLatLongValueAutomatically()
{
string country = null, state = null, city = null, street = null;//, zip = null;
//--This portion fill the lat,long and elevation value is not present in the database by users..
//--Lets do some connection checking and validating the data returned...
string databasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string databaseFile = databasePath + @"\db_psychrometric_project.s3db";
string connString = @"Data Source=" + databaseFile + ";Version=3;";
using (SQLiteConnection connection = new SQLiteConnection(connString))
{
connection.Open();
SQLiteDataReader reader = null;
string queryString = "SELECT * from tbl_building_location WHERE selection=1";
SQLiteCommand command = new SQLiteCommand(queryString, connection);
reader = command.ExecuteReader();
while (reader.Read())
{
//ListboxItems.Add(reader[1].ToString()+","+reader[2].ToString());
country = reader["country"].ToString();
state = reader["state"].ToString();
city = reader["city"].ToString();
street = reader["street"].ToString();
// zip = reader["zip"].ToString();
}
}
// MessageBox.Show("Country = " + country + ",city " + city);
pull_data_online(country, state, city, street);//--This will fill the online values form the database
//--After pulling above we get three values we need to push it to database...
// MessageBox.Show("inside FillLatLongValueAutomatically lat pulled value=" + latPulledValue + ",long = " + longPulledValue + ",elev = " + elevationPulledValue);
//--Upadating the table which has no values ...
using (SQLiteConnection connection = new SQLiteConnection(connString))
{
connection.Open();
string sql_string = "UPDATE tbl_building_location SET latitude=@latitude_value,longitude=@longitude_value,elevation=@elevation where selection=1;";
SQLiteCommand command = new SQLiteCommand(sql_string, connection);
command.CommandType = CommandType.Text;
command.Parameters.AddWithValue("@latitude_value", latPulledValue.ToString());
command.Parameters.AddWithValue("@longitude_value", longPulledValue.ToString());
command.Parameters.AddWithValue("@elevation", elevationPulledValue.ToString());
command.ExecuteNonQuery();
}
}
private void pull_data_online(string country1, string state1, string city1, string street1)