Hi all I have an small application to add the expense of the day.
For this I am using SQL compact database (CE). While inserting the record into a table name Expenses I am getting error
The specified table does not exist. [Expenses]
Insertion code is
using (var con =new SqlCeConnection(@"Data Source=|DataDirectory|\Database\Acadamy.sdf;
Persist Security Info=False"))
{
con.Open();
try
{
var Cmd = new SqlCeCommand();
String sqlAddNew = @"INSERT INTO Expenses (name, amount,receipt,details)
Values(@name,@amount,@receipt,@details)";
Cmd = new SqlCeCommand(sqlAddNew, con);
Cmd.Parameters.Add("@name", SqlDbType.NVarChar).Value = txtName.Text;
Cmd.Parameters.Add("@amount", SqlDbType.NVarChar).Value = txtAmount.Text;
Cmd.Parameters.AddWithValue("@receipt", SqlDbType.NVarChar).Value = txtRecept.Text;
Cmd.Parameters.AddWithValue("@details", SqlDbType.NVarChar).Value = txtDetails.Text;
Cmd.ExecuteNonQuery();
}
catch (Exception exception)
{
txtAmount.Text = exception.ToString();
}
finally
{
if (con.State == ConnectionState.Open) con.Close();
}
}
}
I am not getting why this error occurring. Acadamy.sdf structure is as below:
I am able to retrieve data from another table of the same database. What will be the problem?