using System.Data.Odbc; // in order to use database
private void button_login_Click (object sender, EventArgs e)
{
string strSqlQuery = string.Format ("select * from USER where username =‘ {0} ‘;", textBox_username.Text);
string connStr = "";
connStr + = "Dsn = SQLite3 Datasource; database = D: \\ database \\ jiche.db; StepAPI = 0; SyncPragma =; NoTXN = 0; Timeout =; ShortNames = 0; LongNames = 0; NoCreat = 0; NoWCHAR = 0; FKSupport = 0; JournalMode =; OEMCP = 0; LoadExt =; BigInt = 0; JDConv = 0; ";
// cnStr + = "Driver = {SQLite3 ODBC Driver}; database = D: \\ database \\ jiche.db; StepAPI = 0; SyncPragma =; NoTXN = 0; Timeout =; ShortNames = 0; LongNames = 0; NoCreat = 0; NoWCHAR = 0; FKSupport = 0; JournalMode =; OEMCP = 0; LoadExt =; BigInt = 0; JDConv = 0; ";
OdbcConnection conn = new OdbcConnection (connStr);
OdbcDataAdapter da = new OdbcDataAdapter (strSqlQuery, conn); // Reference database connection dbconn and create OleDbDataAdapter object da according to SQL statement "select * from kaizhi"
DataSet ds = new DataSet (); // Create DataSet object
da.Fill (ds);
if (ds.Tables [0] .Rows.Count> = 1)
{
if (ds.Tables [0] .Rows [0] ["password"]. ToString () == textBox_password.Text)
{
//MessageBox.Show("Login successful ");
FormMain form_main = new FormMain (this);
form_main.Show ();
this.Hide ();
}
}
}
Try it this morning, with OLE DB is not connected, and replaced by ODBC.
C # Connect with SQLite ODBC driver