Re: URGENT! Create Database Error
From: gfeighny (anonymous_at_discussions.microsoft.com)
Date: 03/31/04
- Previous message: Geoff Schwab [MSFT]: "Re: Transfer file to emulator ?"
- In reply to: William Ryan eMVP: "Re: URGENT! Create Database Error"
- Next in thread: William Ryan eMVP: "Re: URGENT! Create Database Error"
- Reply: William Ryan eMVP: "Re: URGENT! Create Database Error"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 31 Mar 2004 12:41:07 -0800
Ryan
localDBFile = "\Program Files\PocketMTrak\MTrak.sdf";
localDBConnection="Data Source=\Program Files\PocketMTrak\MTrak.sdf";
are my variables. one is a file reference, and the other is the database connection string.
Attempted the Assert, and everything looks ok, even did a hard reset, and reloaded everything.
I am now in the process or reseting the device that this DOES work on.
----- William Ryan eMVP wrote: -----
One other thing, it may already exist b/c what you are deleting isn't the
same variable name so it might be referencing something different. Say that
@strLocalConn = "DataSource = myFile.sdf; Password = whatever";
but @strLocalDbFile is "DataSource = SomeOther.sdf; Password = whatever";
You check for the existence of the second and delete it if you find it,
however, you aren't checking for the first (unless of course you are
positive they are the same file). Hence a
Debug.Assert(File.Exist("@strLocalConn")) might be helpful ...if you see a
big ugly assertion box, then that's not the problem, but if the assertion
doesn't fail, it means strLocalConn does exist and isn't letting you create
over it. In any case, having both is just going to be confusing and adding
an @ at the beginning is probably confusing too since that's the prefix for
SQL SErver parameters but these are just variables.
You can also assert (@strLocalDbFile == @strLocalConn) ; if this succeeds
then the strings match so the delete check you do will be valid, otherwise
it won't be.
Let me know if the Path in fact exists, and if the file exists, one of those
is probably the problem.
"gfeighny" <anonymous@discussions.microsoft.com> wrote in message
news:A636764D-03CC-4FBB-865F-692D27D91C01@microsoft.com...
> Keep getting error: SQL Server CE encountered problems in creating the SQL
Server CE database. [,,,Connection string,,]
>>>> //-- delete database file
> if (File.Exists(@strLocalDBFile))
> {
> File.Delete(@strLocalDBFile);
> }
> //-- create local database
> SqlCeEngine engine = new SqlCeEngine();
> engine.LocalConnectionString = @strLocalConn;
>> engine.CreateDatabase();
>> Error happens on CreateDatabase Command. Oddly this code works on 1 device
I have but not on others!
> The local file name and database string are good, because they work on
other devices
>> Any ideas, I'm in a big crunch!
>> thanks
- Previous message: Geoff Schwab [MSFT]: "Re: Transfer file to emulator ?"
- In reply to: William Ryan eMVP: "Re: URGENT! Create Database Error"
- Next in thread: William Ryan eMVP: "Re: URGENT! Create Database Error"
- Reply: William Ryan eMVP: "Re: URGENT! Create Database Error"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|