as the topic name i can only update My SQLite
DB only on time i use this Code to Generate the Database and it's Table
public static void GenDB()
{
if (!System.IO.File.Exists("Key.sqlite"))
{
SQLiteConnection.CreateFile("Key.sqlite");
SQLiteConnection m_dbConnection;
m_dbConnection =
new SQLiteConnection("Data Source=Key.sqlite;Version=3;");
m_dbConnection.Open();
string createTableQuery = @"CREATE TABLE IF NOT EXISTS [MyKey] (
[ID] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
[Key] VARCHAR(2048) NULL
)";
SQLiteCommand command = new SQLiteCommand(createTableQuery, m_dbConnection);
command.ExecuteNonQuery();
try
{
SQLiteConnection dbConnection;
dbConnection =
new SQLiteConnection("Data Source=Key.sqlite;Version=3;");
string sql = "insert into MyKey (Key) values ('yourkey')";
SQLiteCommand commmand = new SQLiteCommand(sql, dbConnection);
dbConnection.Open();
commmand.ExecuteNonQuery();
MessageBox.Show("Done");
}
catch
{
MessageBox.Show("Error with adding to item to your Database ");
}
}
and this worked prefect .. the problem in this
try
{
string con = "Data Source=Key.sqlite;Version=3;";
SQLiteConnection updata = new SQLiteConnection(con);
updata.Open();
string sql = "UPDATE MyKey SET Key=('" + Textbox + "') WHERE ID=1";
SQLiteCommand commmand = new SQLiteCommand(sql, updata);
commmand.ExecuteNonQuery();
MessageBox.Show("Done");
}
catch
{
MessageBox.Show("Error with updata to sql lite ");
}
it's work for the first time .. and when i try to build it again i get error with update to DB
.
Aucun commentaire:
Enregistrer un commentaire