0

I am working on a small project. Building a text based football simulator. I have set up an database with SQLite with the basic information such as Name, Surname, Attack, Defense what I need some help with is reading the database into my C# script to be able to use these values in my existing database.

In short I want to call on a player with C# and read the information in the database into a variable for me to do further calculations with.

Thanks in advance.

  • This should help you > https://stackoverflow.com/questions/29192919/getting-data-from-the-sqlite-db-into-c-sharp-string – dweb Jun 29 '20 at 15:53

1 Answers1

0

On Windows, as well as Linux, you can use ADO.NET and a DataSet with a SQLite ODBC Driver.

http://www.ch-werner.de/sqliteodbc/

It is simple, and it works fine.

You will be able to use VS Designers tools as well as to have strongly typed classes.

The only first thing you will need is to create a connection using the Windows ODBC Data Source Tool.

Or you can use a reg file like :

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\DatabaseName]
"Driver"="C:\\Windows\\system32\\sqlite3odbc.dll"
"Description"=""
"Database"="%USERPROFILE%\\AppData\\Roaming\\Company\\Application\\DatabaseName.sqlite"
"Timeout"=""
"StepAPI"="0"
"SyncPragma"=""
"NoTXN"="0"
"ShortNames"="0"
"LongNames"="0"
"NoCreat"="0"
"NoWCHAR"="0"
"FKSupport"="1"
"OEMCP"="0"
"LoadExt"=""
"BigInt"="0"
"JDConv"="0"
"PWD"=""

[HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\ODBC Data Sources]
"DatabaseName"="SQLite3 ODBC Driver"

Replace DatabaseName, Company and Application by what you want, or use any path and extension you need.

You can install the x32 or x64 driver or both.

Then you can use the VS Designer generated typed child DataSet and any other classes, and/or the OdbcConnection class and OdbcCommand...

I recommend you this book if you need to learn ADO.NET:

Beginning C# 2005 Databases