I am making an application to get data from an xml url/file, and then save the data onto a database. All my other code seems fine, but on my insert I keep getting an error.
Here is the error
Error 1 An object reference is required for the non-static field, method, or property 'DataSet1TableAdapters.vehiclesTableAdapter.InsertCars(string, string, string, string, string, decimal, decimal, string, string, string, string, string, string)'
I tried converting to decimal at first, when that didn't work I tried the below.
vehiclesTableAdapter.InsertCars(dr["REGNO"].ToString(), dr["STOCKNO"].ToString(), dr
["COLOUR"].ToString(), dr["NEWUSED"].ToString(), dr["MODELYEAR"].ToString(), Convert.ToDecimal
(Convert.ToInt16(dr["MILEAGE"].ToString())), Convert.ToDecimal(Convert.ToInt16(dr
["RETAILPRICE"].ToString())), dr["MMCODE"].ToString(), dr["IMAGE_URL1"].ToString(), dr
["IMAGE_URL2"].ToString(), dr["IMAGE_URL3"].ToString(), dr["IMAGE_URL4"].ToString(), dr
["DESCRIPTION"].ToString());
This is for MILEAGE and RETAILPRICE
And I still get the same error. May I kindly have some assistance in this regard.
EDIT:
Button click event code:
DataSet cars = new DataSet();
cars.ReadXml("example.com/example.xml");
progressBar1.Maximum = cars.Tables[2].Rows.Count;
foreach (DataRow dr in cars.Tables[2].Rows)
{
vehiclesTableAdapter.InsertCars(SameAsAbove);
progressBar1.Value++;
}