Hello,
Going through your code posted I don't see the SQL Query ( getLatestCustomerIDQuery) passed to the command object. Please add code to pass the SQL Query to the command object ;
eg : getLatestCustomerIDCommand.CommandText = getLatestCustomerIDQuery;
public static int getLatestCustomerID()
{
int latestCustomerID = 0;
const string getLatestCustomerIDQuery = @"select max(CustomerID) from Customers as 'latest'";
try
{
using (SQLiteConnection getLatestCustomerIDConnection = new SQLiteConnection(conString))
{
getLatestCustomerIDConnection.Open();
using (SQLiteCommand getLatestCustomerIDCommand = getLatestCustomerIDConnection.CreateCommand())
{
getLatestCustomerIDCommand.CommandText = getLatestCustomerIDQuery;
object obj_latestCustomerID = getLatestCustomerIDCommand.ExecuteScalar();
string str_latestCustomerID = obj_latestCustomerID.ToString();
if (str_latestCustomerID.Length == 0)
latestCustomerID = 0;
else
latestCustomerID = int.Parse(str_latestCustomerID);
}
}
}
catch (Exception ex) { throw ex; }
return latestCustomerID;
}