Sqlite on system account

182 views Asked by At

I created a C# application that uses an sqlite database

my app should run on system account.

when i was running my app on system account , it was working very well but when the app started to use sqlite , it sent an error and my app was closed ...

update:

error was append in clsCon.con.State

my code:

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApplication9
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void login_key_Click(object sender, RoutedEventArgs e)
        {

            //check connection is open . if it's close that and open again
            if (clsCon.con.State == ConnectionState.Open)
                clsCon.con.Close();

            clsCon.con.Open();

            // create a database object
            DB DB_OBJECT = new DB();


            //check user pass query
            string result_query;

            result_query = DB_OBJECT.check_user_pass(username.Text, password.Password);


            MessageBox.Show(result_query);

            clsCon.con.Close();
        }
    }
}

//--------------------------------

  class clsCon
        {
            public static SQLiteConnection con = new SQLiteConnection("Data Source=Test.s3db");

            public clsCon()
            {
            }
        }

//--------------------------------

class DB
    {
        public string check_user_pass(string username, string password)
        {

            string string_result = "e1";
            SQLiteCommand cmd = new SQLiteCommand();
            String sSQL = "";

            sSQL = "Select * from tbl_user Where username = '" + username + "'" + " AND password = '" + password + "'";



            cmd.CommandText = sSQL;
            cmd.Connection = clsCon.con;
            SQLiteDataReader dr3;
            dr3 = cmd.ExecuteReader();


            int counter = 0;
            while (dr3.Read())
            {
                counter++;
            }

            if (counter == 0) { string_result = "e1"; }
            else { string_result = "success"; }

            return string_result;
        }
    }
0

There are 0 answers