0
  string path = Path.Combine(
         System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal),
          "Service.db3");

            SqliteConnection cn = new SqliteConnection("Data Source=" + path + " ");

            List<String> entries = new List<string>();


            SqliteCommand sqCommand = (SqliteCommand)cn.CreateCommand();
            sqCommand.CommandText = $"SELECT ID FROM Members ";
            cn.Open();

  SqliteDataReader sqReader = sqCommand.ExecuteReader();

            if (sqReader.HasRows)
            {

            }
            else
            {

            }

that is my code I'm using but there is no row although I have 2 rows at the table and if I used

SELECT name FROM sqlite_master I got the table name that I created I don't understand??

7
  • are you using the right nuget package? The constructor for SqlConnection takes a path, not a connection string. And how are you pre-populating your database? This is a slightly non-trivial process, not something most people get right the first time. Commented Feb 19, 2020 at 22:18
  • github.com/praeclarum/sqlite-net Commented Feb 19, 2020 at 22:25
  • I used sqlite-net-pcl this nuget package before but ummm I couldn't use it i was getting error no such table Members and it was created one Commented Feb 20, 2020 at 9:46
  • then you should solve those errors Commented Feb 20, 2020 at 11:07
  • I'm Trying I don't know where is the problem at my code or at my database Commented Feb 20, 2020 at 11:11

2 Answers 2

1

I know the answer now I have to make function create the db and table I was creating the db with sqlite studio and save it

Sign up to request clarification or add additional context in comments.

Comments

0
string path = Path.Combine(
     System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal),
      "Service.db3");

        SqliteConnection cn = new SqliteConnection("Filename=" + path);

        List<String> entries = new List<string>();


        SqliteCommand sqCommand = (SqliteCommand)cn.CreateCommand();
        sqCommand.CommandText = "SELECT ID FROM Members ";
        cn.Open();

         SqliteDataReader sqReader = sqCommand.ExecuteReader();

        if (sqReader.HasRows)
        {

        }
        else
        {

        }

Try this

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.