Unrecognized Escape Sequence with SQL 2005 Express

Posts   
 
    
jflegere
User
Posts: 33
Joined: 22-Jul-2005
# Posted on: 17-Nov-2005 20:15:43   

I just moved my DB over to SQL Server 2005 Express and regenerated my code (Adapter, VS.NET 2005 with C# Template set for SQL Server).

On compilation, the generated code produced several "Unrecognized Escape Sequence" errors. The errors seem to be caused by file paths (unique to the Express .MDF file architecture?). The "escape sequences" that are underlined by the compiler are all of the "\letter" strings in the file paths.

Any help? Thanks.


        private static PersistenceInfoBucket CreateEventEntityBucket()
        {
            PersistenceInfoBucket toReturn = new PersistenceInfoBucket();
            toReturn.AddFieldPersistenceInfo("EventId", new FieldPersistenceInfo("C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL.1\MSSQL\DATA\CMS_DATA.MDF", @"dbo", "Event", "EventID", false, (int)SqlDbType.Int, 0, 0, 10, false, "", null, typeof(System.Int32)));
            toReturn.AddFieldPersistenceInfo("Name", new FieldPersistenceInfo("C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL.1\MSSQL\DATA\CMS_DATA.MDF", @"dbo", "Event", "Name", false, (int)SqlDbType.VarChar, 100, 0, 0, false, "", null, typeof(System.String)));
            toReturn.AddFieldPersistenceInfo("Description", new FieldPersistenceInfo("C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL.1\MSSQL\DATA\CMS_DATA.MDF", @"dbo", "Event", "Description", false, (int)SqlDbType.VarChar, 1000, 0, 0, false, "", null, typeof(System.String)));
            toReturn.AddFieldPersistenceInfo("StartDateTime", new FieldPersistenceInfo("C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL.1\MSSQL\DATA\CMS_DATA.MDF", @"dbo", "Event", "StartDateTime", false, (int)SqlDbType.DateTime, 0, 0, 0, false, "", null, typeof(System.DateTime)));
            toReturn.AddFieldPersistenceInfo("EndDateTime", new FieldPersistenceInfo("C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL.1\MSSQL\DATA\CMS_DATA.MDF", @"dbo", "Event", "EndDateTime", true, (int)SqlDbType.DateTime, 0, 0, 0, false, "", null, typeof(System.DateTime)));
            toReturn.AddFieldPersistenceInfo("LocationId", new FieldPersistenceInfo("C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL.1\MSSQL\DATA\CMS_DATA.MDF", @"dbo", "Event", "LocationID", false, (int)SqlDbType.Int, 0, 0, 10, false, "", null, typeof(System.Int32)));
            toReturn.AddFieldPersistenceInfo("RecurrenceId", new FieldPersistenceInfo("C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL.1\MSSQL\DATA\CMS_DATA.MDF", @"dbo", "Event", "RecurrenceID", false, (int)SqlDbType.Int, 0, 0, 10, false, "", null, typeof(System.Int32)));
            toReturn.AddFieldPersistenceInfo("LastDateScheduled", new FieldPersistenceInfo("C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL.1\MSSQL\DATA\CMS_DATA.MDF", @"dbo", "Event", "LastDateScheduled", true, (int)SqlDbType.DateTime, 0, 0, 0, false, "", null, typeof(System.DateTime)));
            toReturn.AddFieldPersistenceInfo("AllDatesScheduled", new FieldPersistenceInfo("C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL.1\MSSQL\DATA\CMS_DATA.MDF", @"dbo", "Event", "AllDatesScheduled", false, (int)SqlDbType.Bit, 0, 0, 0, false, "", null, typeof(System.Boolean)));

            return toReturn;
        }

wojt
User
Posts: 20
Joined: 27-Oct-2005
# Posted on: 17-Nov-2005 20:19:44   

I am just a user, but at first glance, you could put an @ in front of all the strings, so the backslashes act as backslashes (e.g. @"C:\blah"). If this is in the generated code then I guess its a bug that needs fixing...

jflegere
User
Posts: 33
Joined: 22-Jul-2005
# Posted on: 17-Nov-2005 20:39:25   

Yeah, it's generated. Might be a quick change to a template but I'll wait to see...

Thanks.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 17-Nov-2005 21:27:01   

In the Drivers\SqlServer\Templates\C# folder, you'll find a template called: persistenceInfoFactoryAdapter.template . In there at line: 180, you'll see: "<[SourceCatalogName]>", add a @ in front of it. Also on line 194.

It's very inefficient though. I've to change the SqlServer driver to accept sqlserver express connections, so the catalog is just the filename and the connection string contains the full path. Now in a query this will lead to very long queries, which is not useful. Isn't there a service you can talk to with sqlserver express?

Frans Bouma | Lead developer LLBLGen Pro
jflegere
User
Posts: 33
Joined: 22-Jul-2005
# Posted on: 17-Nov-2005 21:37:23   

There is a service (I think) but how do i get LLBLGen to "talk" to it? When I connnect to the instance (machine\instance) all that I see in the "Catalogs to use" is this thing with a long path name.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 17-Nov-2005 21:58:59   

jflegere wrote:

There is a service (I think) but how do i get LLBLGen to "talk" to it? When I connnect to the instance (machine\instance) all that I see in the "Catalogs to use" is this thing with a long path name.

I'll check it out. Sqlserver express isn't supported officially yet, due to the filename vs. service changes, the connection control for example doesn't allow to browse to a file. And IF a file is chosen, it's not properly handled. I'll look into this tomorrow (friday) to see if I can update the driver code to handle these files properly.

Frans Bouma | Lead developer LLBLGen Pro
jflegere
User
Posts: 33
Joined: 22-Jul-2005
# Posted on: 17-Nov-2005 23:39:10   

Thanks.

I could just go against a SQL Server 2005 server directly but I was hoping to use Express locally for development and then deploy to SQL Server 2005 for production.

jflegere
User
Posts: 33
Joined: 22-Jul-2005
# Posted on: 18-Nov-2005 00:46:42   

Additional information -

I also changed:

actionProceduresAdapter.template retrievalProceduresAdapter.template

and I think it's in a few more template files that my project isn't using.

Thanks,

Jay

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 19-Nov-2005 11:44:38   

If you specify .\SQLEXPRESS

for the server, does it work then?

Frans Bouma | Lead developer LLBLGen Pro
jflegere
User
Posts: 33
Joined: 22-Jul-2005
# Posted on: 19-Nov-2005 15:38:08   

Ok, this is strange... but there is good news.

To answer your question, no, if I specify .\SQLEXPRESS it still shows the database with a file path to the .MDF file.

BUT...

I went into the new SQL Server Management Studio, and in the list of databases, I see some databases listed with paths. For example, if you use the new ASP.NET membership management tool (for managing users, roles, etc. in your web application) the database it creates shows up with a long path like C:.........\ASPNETDB.MDF. But if you create a new database with Management Studio, it just shows only the database's name (e.g., MyDatabase) like it does in good old SQL Enterprise Manager.

So, I created a new database using Management Studio, scripted all of the tables, views, SPs, etc. over to the new DB, fired up LLBLGen Pro, connected to SQL Express and there was the new database WITHOUT all of the file path stuff. I went back to the template folder and took out the "@"s that I added yesterday (not necessary, I know, but I wanted to see if the resulting generated code would compile). And, IT WORKED!

So, I'm not sure what I did when I created the "problem" database, but now everything appears to be OK.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 19-Nov-2005 19:00:57   

Thanks Jay for this excellent feedback! simple_smile I'll create a FAQ out of this till I've rewritten the SqlServer driver interface to support mdf files directly.

Frans Bouma | Lead developer LLBLGen Pro
jflegere
User
Posts: 33
Joined: 22-Jul-2005
# Posted on: 21-Nov-2005 00:21:15   

No problem, thanks for all your hard work on the product, it's great!