我想在我的Asp.Net中使用SqLite。我有下面的代碼在web.config中的ConnectionString在Asp.Net中使用SqLite
<add name="ConnectionStringName" connectionString="data source=MembersLastLogin3.s3db" providerName="System.Data.SQLite" />
這裏是運行查詢
public int ExecuteNonQuery(string sql)
{
try
{
string con = ConfigurationManager.ConnectionStrings["ConnectionStringName"].ConnectionString;
SQLiteConnection cnn = new SQLiteConnection(con);
cnn.Open();
SQLiteCommand mycommand = new SQLiteCommand(cnn);
mycommand.CommandText = sql;
int rowsUpdated = mycommand.ExecuteNonQuery();
cnn.Close();
return rowsUpdated;
}
catch { throw; }
}
}
的代碼,這簡單的查詢
sql = "INSERT INTO LastLogin (MemId) VALUES ('" + res + "');";
LocalDb.ExecuteNonQuery(sql);
,但我得到的錯誤「表LastLogin不存在「
我已經使用了SqLitein .Net,但這是我第一次使用它在Asp.Net中,我確定表格存在,但它似乎可以連接到它,我的問題在哪裏? web.config中的設置是否足夠?有沒有可用的教程?感謝