Re: URGENT! Create Database Error

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: William Ryan eMVP (dotnetguru_at_comcast.nospam.net)
Date: 03/31/04


Date: Wed, 31 Mar 2004 15:09:13 -0500

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



Relevant Pages

  • Re: Linking tables access - sql server 2005
    ... Another advantage of this method is that you don't need an ODBC setting on the local computer, ... Create a linked table to SQL Server without using a DSN ... Name of the table that you are linking to on the SQL Server database ... Function AttachDSNLessTable(stLocalTableName As String, stRemoteTableName As String, stServer As String, stDatabase As String, Optional stUsername As ...
    (microsoft.public.access.adp.sqlserver)
  • Re: Cannot Generate SSPI Context - help
    ... I have used the following DSN-less string: ... Microsoft OLE DB Provider for SQL Server error '80004005' ... When a connection is "trusted," it means ... > How would one connect to a remote SQL Server using Windows authen? ...
    (microsoft.public.inetserver.asp.db)
  • Re: INSERT Query problem with Quotes & Apostrophes
    ... I've got front-ends that go against both Jet and SQL Server databases. ... InputText As String, _ ... >> Delimiter, Delimiter & Delimiter) ... dDateTime, ...
    (microsoft.public.access.modulesdaovba)
  • Re: ADO.NET 2.0 saving single space to SQL?
    ... It is code someone else wrote quite some time ago and all of the string ... Hitchhiker's Guide to Visual Studio and SQL Server ... and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook) ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: using OpenXML in T-sql?
    ... am not the most senior person in sql server programming, ... especially xml stuff. ... style string in place of an array without the additional ... >delimited strings and opts for the xml string instead. ...
    (microsoft.public.sqlserver.programming)