Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6811529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:20:21+00:00 2026-05-26T20:20:21+00:00

I created a *.sdf file with password protected using Visual Studio, worked fine. I

  • 0

I created a *.sdf file with password protected using Visual Studio, worked fine. I insert some data and I tried read using Visual Studio SQL editor, but when I went to the C # code that did not work.

I tried the following:

using System;
using System.Data.SqlServerCe;


    class Program
    {
        static void Main(string[] args)
        {
            var conStr = @"data source=C:\path\db.sdf; password=<...>";
            SqlCeConnection con = new SqlCeConnection(conStr);
            con.Open();

            SqlCeCommand cmd = con.CreateCommand();
            cmd.CommandText = "select * from Cookies";
            cmd.CommandType = System.Data.CommandType.TableDirect;
            cmd.Connection = con;

            SqlCeDataReader result = cmd.ExecuteReader();
            //...
            con.Close();
        }
    }

I getting the following error:
The specified table does not exist. [ select * from Cookies ]

The table structure

enter image description here

This returns false. Someone can point my mistake?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:20:22+00:00Added an answer on May 26, 2026 at 8:20 pm

    Your problem is that you’re specifying System.Data.CommandType.TableDirect.

    When you change your code to use the following, you’ll avoid the error you’re seeing.

    cmd.CommandType = System.Data.CommandType.Text;
    

    You can even exclude setting the CommandType property, as Text is the default.

    TableDirect is an OLEDB legacy command type. Don’t use it unless your command is only a table or view name. Internally, the command object will construct a SELECT * FROM statement, selecting all fields and all records from the specified table or view.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a SDF (SQL CE) database with Visual Studio 2008 (Add / New
I created a simple .NET windows application in Visual Studio 2005 and on just
I'm using Visual Studio 2008 Pro. I'm probably missing something very obvious here, but
Using SQL ManagementStudio 2008 I created SQL 3.5 Compact DB (TestCompact.sdf) and I have
Created basic C++ DLL and exported names using Module Definition file (MyDLL.def). After compilation
I am a newbie in C#. I created a local database in VS2010(.sdf file).
I'm using C# 2010 Express. I have created a SQL Server CE database file
I've created a new project in .Net (2010 4.0) and added an SDF data
I'm developing a Windows Forms application using Visual Studio 2008 C# that uses an
I am writing a program in C# using Visual Studio 2010 and gets an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.