How can i insert many data using arraylist in c# and save all the data in database .mdb file ?
How can i add arraylist in name, latitude and longitude so these three things user can input many data on it and save the data in database?
Here is my code:
How can i add arraylist in name, latitude and longitude so these three things user can input many data on it and save the data in database?
Here is my code:
Code:
string myConnectionString = "";
myConnectionString = "Provider =Microsoft.Jet.OLEDB.4.0; Data Source=E:\\Placemark.mdb";
OleDbConnection myConnection = new OleDbConnection(myConnectionString);
string myInsertQuery = "INSERT INTO placemark " + "(Name, Latitude, Longitude)" + "VALUES(@Name, @Latitude, @Longitude)";
OleDbCommand myCommand = new OleDbCommand(myInsertQuery);
myCommand.Connection = myConnection;
myCommand.CommandText = myInsertQuery;
myCommand.CommandType = CommandType.Text;
myCommand.Parameters.Add("Name", OleDbType.Char).Value = textBoxPlacemark.Text;
myCommand.Parameters.Add("Latitude", OleDbType.Char).Value = latitude.Text;
myCommand.Parameters.Add("Longitude", OleDbType.Char).Value = longitude.Text;
myConnection.Open();
try
{
//reader = myCommand.ExecuteReader();
myCommand.ExecuteNonQuery();
MessageBox.Show("record are successful insert");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
myConnection.Close();
}
private void HandleConnection(OleDbConnection myConnection)
{
throw new NotImplementedException();
}
}
Comment