9 Replies - 1182 Views - Last Post: 06 August 2010 - 09:15 PM Rate Topic: -----

#1 agent1   User is offline

  • D.I.C Head
  • member icon

Reputation: 7
  • View blog
  • Posts: 73
  • Joined: 09-July 10

SQL Server Compact issue

Posted 06 August 2010 - 07:53 AM

Hi there

Im using sql server compact 3.5 inside an application in VS2008.
I would like to use linq to sql to interact with the database but the VS OR designer doesnt support SQL server compact directly so Ive created the dbml file via the sqlmetal.exe tool and then added it to my project accordingly and it works fine.

However everytime i try to instantiate my context I get this error

The type initializer for 'EmailNewsletterApp.Data.Mail_Data' threw an exception.

Mail_Data is my DataContext class.

Im using the constructor which takes a connection string argument

public Mail_Data(string connection) :
base(connection, mappingSource)
{
OnCreated();
}

and im calling it like this


using (Mail_Data db = new Mail_Data(EmailNewsletterApp.Properties.Settings.Default.MailDataConnectionString))



there is nothing wrong with the connection string but ill post it anyway

<connectionStrings>
<add name="EmailNewsletterApp.Properties.Settings.MailDataConnectionString" connectionString="Data Source=|DataDirectory|\Data\Mail.Data.sdf"
providerName="Microsoft.SqlServerCe.Client.3.5" </connectionStrings>


does anyone have any ideas how i could resolve this?


thanks very much

This post has been edited by agent1: 06 August 2010 - 08:09 AM


Is This A Good Question/Topic? 0
  • +

Replies To: SQL Server Compact issue

#2 Ionut   User is offline

  • D.I.C Lover
  • member icon

Reputation: 386
  • View blog
  • Posts: 1,057
  • Joined: 17-July 10

Re: SQL Server Compact issue

Posted 06 August 2010 - 07:56 AM

And what's the issue?
Was This Post Helpful? 0
  • +
  • -

#3 Bacanze   User is offline

  • D.I.C Head

Reputation: 36
  • View blog
  • Posts: 202
  • Joined: 09-April 10

Re: SQL Server Compact issue

Posted 06 August 2010 - 07:57 AM

Some information on the problem here:

http://pietschsoft.c...ct-Edition.aspx
Was This Post Helpful? 1
  • +
  • -

#4 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12657
  • View blog
  • Posts: 45,831
  • Joined: 27-December 08

Re: SQL Server Compact issue

Posted 06 August 2010 - 07:58 AM

So what exactly is your question?
Was This Post Helpful? 0
  • +
  • -

#5 eclipsed4utoo   User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1536
  • View blog
  • Posts: 5,972
  • Joined: 21-March 08

Re: SQL Server Compact issue

Posted 06 August 2010 - 08:01 AM

View PostIonut, on 06 August 2010 - 10:56 AM, said:

And what's the issue?


View Postmacosxnerd101, on 06 August 2010 - 10:58 AM, said:

So what exactly is your question?


by default, LINQ-To-SQL doesn't support SQL CE in the designer. That's probably his issue. Bacanze's link should help him fix his issue.
Was This Post Helpful? 0
  • +
  • -

#6 agent1   User is offline

  • D.I.C Head
  • member icon

Reputation: 7
  • View blog
  • Posts: 73
  • Joined: 09-July 10

Re: SQL Server Compact issue

Posted 06 August 2010 - 08:02 AM

ammended the post I must have made a mistake

This post has been edited by agent1: 06 August 2010 - 08:10 AM

Was This Post Helpful? 0
  • +
  • -

#7 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12657
  • View blog
  • Posts: 45,831
  • Joined: 27-December 08

Re: SQL Server Compact issue

Posted 06 August 2010 - 08:04 AM

Duplicate topics merged. Please avoid duplicate posting.
Was This Post Helpful? 0
  • +
  • -

#8 agent1   User is offline

  • D.I.C Head
  • member icon

Reputation: 7
  • View blog
  • Posts: 73
  • Joined: 09-July 10

Re: SQL Server Compact issue

Posted 06 August 2010 - 08:05 AM

sorry i must have pressed enter or something by mistake, please check the thread above this one
Was This Post Helpful? 0
  • +
  • -

#9 eclipsed4utoo   User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1536
  • View blog
  • Posts: 5,972
  • Joined: 21-March 08

Re: SQL Server Compact issue

Posted 06 August 2010 - 09:36 AM

look at the inner exception for the error. that should give you a better error message.
Was This Post Helpful? 1
  • +
  • -

#10 agent1   User is offline

  • D.I.C Head
  • member icon

Reputation: 7
  • View blog
  • Posts: 73
  • Joined: 09-July 10

Re: SQL Server Compact issue

Posted 06 August 2010 - 09:15 PM

Thanks for the help eclipsed, I found out the problem, I have a partial datacontext class for some utility methods on the db and in there I had forgotten to inherit the class from Datacontext, checking the innerException led me straight there.

This post has been edited by agent1: 06 August 2010 - 09:17 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1