C # Connect with SQLite ODBC driver

Source: Internet
Author: User
Tags sqlite


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


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.