- Home /
Saving drop down menu selection
Having some trouble here, hopefully someone can help. I have a drop-down menu that I am able to to get the data from the field, only when the save function fires off, it doesn't save it, the info is blank. I tried to set it up that the function returned the string, only I'm taking in an int to show the selection number, so it's not compatible. Any thoughts? Yes, the string is public.
public string GetDropSelection(int index)
{
Debug.Log(index);
switch (index)
{
case 1: BrakeWheelField="Front";
break;
case 2: BrakeWheelField="Rear";
break;
case 3: BrakeWheelField="Both";
break;
}
return BrakeWheelField; I know this technique doesn't work because what is coming in is not what's going out.
Debug.Log("What is the selection?" + BrakeWheelField); Variable has the value here.
}
public void GetBrakeData(string BrakeWheelField)
{
Debug.Log(BrakeWheelField); By the time it gets to here, it's blank.
BrakeDateofPurchaseField=BrakeDateofPurchaseText.text;
BrakeMileageField=BrakeMileageText.text;
BrakeLocationField=BrakeLocationText.text;
BrakeLaborField=BrakeLaborText.text;
BrakeBrandField= BrakeBrandText.text;
BrakePriceField= BrakePriceText.text;
BrakeNotesField = BrakeNotesText.text;
DatabaseManager.Instance.SQLiteInit();
DatabaseManager.Instance.SaveBrakeInfo(BrakeDateofPurchaseField, BrakeMileageField, BrakeLocationField, BrakeLaborField, BrakeBrandField, BrakePriceField, BrakeWheelField, BrakeNotesField);
}
Thanks in advance...
Comment
public void SaveBrakeInfo(string BrakeDateofPurchaseField, string Brake$$anonymous$$ileageField, string BrakeLocationField, string BrakeLaborField,
string BrakeBrandField, string BrakePriceField, string BrakeWheelField, string BrakeNotesField, string BrakePurchaseLocationField)
{
//BrakeWheelField=this.BrakeWheelField;
mSQLString = "INSERT OR REPLACE INTO " + SQL_TABLE_BRA$$anonymous$$ES
+ " ("
+ COL_BRA$$anonymous$$E_SERVICE_DATE + ","
+ COL_BRA$$anonymous$$E_SERVICE_LOCATION + ","
+ COL_BRA$$anonymous$$E_$$anonymous$$ILEAGE + ","
+ COL_BRA$$anonymous$$E_LABOR + ","
+ COL_BRA$$anonymous$$E_BRAND + ","
+ COL_BRA$$anonymous$$E_PRICE + ","
+ COL_BRA$$anonymous$$E_WHEELS + ","
+ COL_BRA$$anonymous$$E_PURCHASE_LOCATION + ","
+ COL_BRA$$anonymous$$E_NOTES
+ ") VALUES ("
+ "'" + BrakeDateofPurchaseField + "'," // note that string values need quote or double-quote delimiters
+ "'" + BrakeLocationField + "',"
+ "'" + Brake$$anonymous$$ileageField+ "',"
+ "'" + BrakeLaborField + "',"
+ "'" + BrakeBrandField + "',"
+ "'" + BrakePriceField + "',"
+ "'" + BrakeWheelField + "',"
+ "'" + BrakePurchaseLocationField + "',"
+ "'" + BrakeNotesField +"');";
Debug.Log(mSQLString);
ExecuteNonQuery(mSQLString);
}
This is the singleton code...
Best Answer
Answer by Gilead7 · Nov 22, 2016 at 05:49 PM
I had to add a this to the BrakeWheelField both on the singleton and when I inserted the value into the database. It was reading the local value not the global one.