Step 1: import data to the project in mongodblinq. dll, dblinq. SQLite. dll, system. Data. SQLite. dll, and system. Data. SQLite. LINQ. dll.
Step 2: Execute dbmetal.exe in workshop and enter the database configuration according to the help prompt.
Example: dbmetal.exe-c "dblinqprovider = SQLite; Data Source = test. DB" -- provider = SQLite -- database = testdb -- code = testdb. CS (Testdb. CS is the class file that will inherit datacontext, and testdb is the class name)
Step 3: place the generated file in the Dal layer or app_code of your project and call it in the Aspx. CS or form. CS file.
Example:
-
C # code
-
Sqliteconnection con= NewSqliteconnection ("Dblinqprovider = SQLite; Data Source = test. DB");
Testdb DB= NewTestdb (CON );
Gridview1.datasource=DB. tablename;
Gridview1.databind ();
Note: You must use sqliteconnection to create a database connection. If you directly add the connection string to the constructor parameter, an error may be reported.
about how to use the SQLite database, let's also talk about:
download the SQLite database browser software on www.sf.net and click "new" to specify the database directory, name it test. db3 or test. all databases are supported. This file is the database, and then you can use SQLite database browser to create tables, add fields, and change the data type for the test database, which is very convenient.