I'm new with SQlite database.
I'm trying to insert a new record in sqlite db table "time_sheet_info",
i invoke the DAL method from an .asmx WebService; & get no errors; the ExecuteNonQuery returns 1; but no data appears.
I've tried to execute the insert command inside the WebService; it worked perfectly there!!
Any suggestions?
**NOTE: i access the WS using an auto-generated PROXY.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SaveDataDolCls data = new SaveDataDolCls();
data.intProjectID = 1;
data.intTaskID = 1;
WebService1 wsp = new WebService1();
wsp.saveData(data);
}
}
[WebMethod]
public void saveData(SaveDataDolCls arrData)
{
using (TransactionScope scope = new TransactionScope())
{
obj1.SaveData(arrData);
}
}
SaveDataDolCls obj = new SaveDataDolCls();
public void SaveData(SaveDataDolCls arrData)
{
using (SQLiteConnection conn = new SQLiteConnection())
{
string dbPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DB\\MySqliteDb.db");
string connStr = "data source= " + dbPath + "; version=3;";
conn.ConnectionString = connStr;
conn.Open();
using (SQLiteCommand cmd = new SQLiteCommand(conn))
{
cmd.CommandType = CommandType.Text;
cmd.CommandText = "insert into time_sheet_info (project_id, task_id) values ('1','3');";
int i = cmd.ExecuteNonQuery();
}
conn.Close();
}
}
You have to call scope.Complete
at the end of using
block i.e.:
using (TransactionScope scope = new TransactionScope())
{
obj1.SaveData(arrData);
scope.Complete();
}