This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi,
I'm trying to use Lightspeed to smooth out some of the difficulties with SQL Server Compact. I am not sure what the trouble is; I've created a KeyTable according to the script. I have one table Notes with an id column and a text column. When I run my program and try and insert data into the table, it doesn't actually insert the data.
Here is my code:
LightSpeedContext<LightSpeedModel1UnitOfWork> context = new LightSpeedContext<LightSpeedModel1UnitOfWork>("Development"); using (var unitOfWork = context.CreateUnitOfWork()) { Note n = new Note(); n.Text = "hello world!"; unitOfWork.Add(n); unitOfWork.SaveChanges(); } As you can see, I'm just trying to get started with this ORM and am doing something very simple.
Here's my config section:
<configSections>
<section name="lightSpeedContexts"
type="Mindscape.LightSpeed.Configuration.LightSpeedConfigurationSection, Mindscape.LightSpeed" />
</configSections>
<lightSpeedContexts>
<!-- TODO: Check pluralizeTableNames setting -->
<!-- TODO: Add identityMethod="..." if not using KeyTable -->
<add name="Development"
connectionStringName="Development"
dataProvider="SqlServerCE"
pluralizeTableNames="False" />
</lightSpeedContexts>
<connectionStrings>
<add name="Development"
connectionString="Data Source=C:\Users\ron\documents\visual studio 2010\Projects\WindowsFormsApplication5\WindowsFormsApplication5\Notes.sdf"/>
</connectionStrings>
As you can see, the sdf file is hard coded--so no problem with the fact that VS copies another sdf file when debugging into the DEBUG directory.
Any ideas why it wouldn't be inserting something into the database?
Thanks,
Ron
|
|
|
Your code looks fine, so I think there may be a configuration issue. I'm not certain how SQL CE handles this, but I've seen problems on other databases when there are spaces in a connection string path. Try a connection string with a path with no spaces such as "Data Source=c:\temp\notes.sdf". If that works, try putting quotes around your real path (you'll need to escape them for XML). This may not be the issue, since that connection string was presumably provided by Server Explorer and therefore ought to work, but I think it's worth a quick check. If it doesn't help, let us know. and it would be helpful if you could also tell us: - Whether you're seeing nothing happening at all (as if LightSpeed thinks it's successfully inserted but no data appears), or an exception. - If you're seeing an exception, the exception message. - The generated INSERT statement (you can see this by setting context.Logger = new TraceLogger() -- the SQL will be displayed in the Visual Studio Output window). Thanks! |
|