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 6958347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:07:39+00:00 2026-05-27T15:07:39+00:00

I am using Visual Studios 2010 for this C# program I am making where

  • 0

I am using Visual Studios 2010 for this C# program I am making where I am generating a cache that I want to store in a local database made by the SqlCeEngine class. I want to use the SqlCeEngine class to make this database in a 100% programmatic manner, but I am having problems finding CREATE TABLE examples using MS SQL data types while I am still fairly new to databases and what experience I have had before was with sqlite3.

I want to make a table with a UniqueID column as the PRIMARY KEY, but ideally using a smallint as the datatype for it as this generated cache shouldn’t be exceeding 2^15 entries, or even 1500 entries for that matter. But let’s say I also want to make a second column that holds some text, but I have a hard time determining how long that will be ahead of time. On average, I am expecting 8 characters or less, but I might have the occasional entry that is over 260 characters long. I could just make the string size for the entries set to the maximum length the string is allowed to be (4000 characters I believe), but for this project, space consumption by the cache needs to be minimized and I think that would waste a lot of space. I noticed there were nchar and nvarchar data types, but I didn’t really understand the difference as they both needed a length to be declared. It just seemed like one was hinting towards that it might be more friendly with strings of different lengths under the hood of the SqlCeEngine than the other.

TL;DR

Is there a way to declare a SQL database in C# using the SqlCeEngine class that uses a smallint data type for the primary key column and variable length text in the second column without wasting space?

  • 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-27T15:07:40+00:00Added an answer on May 27, 2026 at 3:07 pm

    You want to use a varchar, unless you’re storing unicode characters, in that case use nvarchar.

    The difference between char(50) and varchar(50) is that char(50) will grab and hold onto 50 characters, whether they’re used or not. varchar(50) will allow up to 50 characters, but if 0 are used, it doesn’t reserve any space.

    So if you had a field char(20) and the value was ‘Name’ the size of that field would be 20 characters, the 4 you specified and an additional 16 to fill it out. If you had a varchar(20) and the value was ‘Name’ the size would be 4.

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

Sidebar

Related Questions

I am making a C program on windows using visual studio 2010. I am
I'm using Visual Studio 2010 RC. Would it be possible that after doing my
I want to be able to develop code using Visual Studio 2010. I just
I'm currently creating a WPF application, using C# and XAML in Visual Studios 2010.
We are using Visual Studio 2010, but this was first conceived with VS2003. I
I'm using Visual studio c++ 2010. My program was working fine until I linked
I am using Visual Studio 2010. I have read that in C++ it is
I have written a program in C# using Visual Studio 2010. At current it
I'm using C# with XNA in Visual Studio 2010 Ultimate. I have a program
I am using Visual Studio 2010 Ultimate. I want to find out which methods

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.