Wednesday, March 21, 2012

DB Size

How do I set the max DB size when creating a DB through Visual Sudio?

I tried to modify it after creating it but I don't see a option to set it.

Thanks

That "feature" is currently missing from the Visual Studio GUI tools. You will have to create the database in code or SQL script.|||

Sounds good.

so script question.

I have a CE DB what is the best way to script out the table structure so that I can then use that script in code to create the table.

Thanks

|||The "best" way is to script the SQL Server tables that correspond to your CE db, and adapt those scripts to the more basic SQL CE Data Definition Language (DDL)...|||

So you have to do it from SQL Server no way to script it from CE?

Also is there a doc you can send me for syntax on creating a table with a PK from a script the basic CE way.

Thanks

|||

No, sadly there is no Microsoft supplied way to script a database. These links may be useful for you:

http://blogs.msdn.com/stevelasker/archive/2007/03/31/creating-your-sql-server-compact-edition-database-and-schema-in-code.aspx

CREATE TABLE http://msdn2.microsoft.com/en-us/library/ms173393.aspx

ALTER TABLE http://msdn2.microsoft.com/en-us/library/ms174123.aspx

(to add FKs, indexes)

|||

In code when i create the db how can i tell it that i want it to be able to grow to the max available size?

SqlCeEngine sqlCEEngine = new SqlCeEngine("Data Source='c:\\temp\\test.sdf';");

sqlCEEngine.CreateDatabase();

There is no option for db size.

|||

Use this:

Code Snippet

SqlCeEngine sqlCEEngine = new SqlCeEngine("Data Source='c:\\temp\\test.sdf';max database size=4000");

sqlCEEngine.CreateDatabase();

for more information, see: http://msdn2.microsoft.com/en-us/library/system.data.sqlserverce.sqlceconnection.connectionstring.aspx

|||

Still getting max size error

The DB i am using was created by scratch using this

SqlCeEngine sqlCEEngine = new SqlCeEngine("Data Source='c:\\temp\\test.sdf';max database size=4000;encrypt=true;password=F562D231-B5EE-4E10-88F1-2B52C6917848;max buffer size=100000;temp file max size=1000 ");

sqlCEEngine.CreateDatabase();

|||What is your "max size error", I don't see that mentioned anywhere else?|||

The database file is larger than the configured maximum database size. This setting takes effect on the first concurrent database connection only. [ Required Max Database Size (in MB; 0 if unknown) = 257

|||And when exactly do you get this error ?|||When trying to insert a new row into the databasase. The database is 256 meg when i try to insert.|||Interesting... could you test without encryption (without a daatabase password)...|||

Same Error when creating DB like this

SqlCeEngine sqlCEEngine = new SqlCeEngine("Data Source='c:\\temp\\test.sdf';max database size=4000;");

sqlCEEngine.CreateDatabase();

So now what does ce really support 4 gig and no one has ever tried itSmile?

sql

No comments:

Post a Comment