mardi 26 mai 2015

SQLite: do much insert

How to make injections into the database was performed with the same database connection.

Now, as soon as there is new data that should be entered in the database I have to connect to the database.

I want to make it so that when you press I created the connection and it always has been. As soon as there is new information that should be entered in the database, I am using this connection input the information into the database.

The problem that I encountered is that from another class, I can't enter data, for example because the connection that you created from another class can't use.

For example:

  SQLiteConnection connection2 = new SQLiteConnection();

  connection2.ConnectionString = "data source = symbols/" + symbol + ".db";

  connection2.Open();

But another class (where i get information) i can't use connection2

  SQLiteCommand command2 = new SQLiteCommand(connection2);

  command2.CommandText = "INSERT INTO " + symbol + " (...) VALUES (...);

  command2.ExecuteNonQuery();

How to make so that I could use connection2 anywhere in the program?

Aucun commentaire:

Enregistrer un commentaire