473,394 Members | 2,031 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Stumped here!

Hi All

I have just installed studio 2008 and created a new winforms app.
I have added a sql express db to the project with 1 table called LogEntries
containing 2 columns: LogEntryID (int, auto inc) and LogEntryData (nvarchar
MAX)

I am running some simple LINQ code:
using (LogEntryDataContext db = new LogEntryDataContext())
{
LogEntry log = new LogEntry();
log.LogEntryData = data; //variable passed in

db.LogEntries.InsertOnSubmit(log);
db.SubmitChanges();
}

All runs perfect with no errors but the table never seems to contain any new
rows??

I am stumped as I get no errors? Is there something I am overlooking?

Thanks

Chev

Dec 11 '07 #1
3 1353
Chevron,

Are you doing this in an event handler by chance? If you are, then
there might be an exception being thrown that is being swallowed by the
control firing the event (which is standard winforms behavior).

If you step through the code in the event handler, or place a try/catch
block in the handler, does it catch an exception?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chevron Boyde" <ev********@gmail.comwrote in message
news:uB**************@TK2MSFTNGP04.phx.gbl...
Hi All

I have just installed studio 2008 and created a new winforms app.
I have added a sql express db to the project with 1 table called
LogEntries containing 2 columns: LogEntryID (int, auto inc) and
LogEntryData (nvarchar MAX)

I am running some simple LINQ code:
using (LogEntryDataContext db = new LogEntryDataContext())
{
LogEntry log = new LogEntry();
log.LogEntryData = data; //variable passed in

db.LogEntries.InsertOnSubmit(log);
db.SubmitChanges();
}

All runs perfect with no errors but the table never seems to contain any
new rows??

I am stumped as I get no errors? Is there something I am overlooking?

Thanks

Chev

Dec 11 '07 #2
Ok I managed to solve the problem. Great waste of 3 hours!

When you add a sql express db to your project to uses AttachDbFilename to
point to the file in you project dir.
When you debug all the relevant files including the DB are copied to the
debug\bin folder. All updates are performed against this db not the db
orginally added. You should set the Copy To Output Directory property of the
file to Copy Never if you want to keep the file in your project.

I prefer adding the connection to the existing DB file and NOT adding the db
to the project.

More resources here:
http://briannoyes.net/PermaLink.aspx...f-aeeef64c4ed1
http://www.msdner.com/dev-archive/16/19-158-169725.shtm

Chev
"Chevron Boyde" <ev********@gmail.comwrote in message
news:uB**************@TK2MSFTNGP04.phx.gbl...
Hi All

I have just installed studio 2008 and created a new winforms app.
I have added a sql express db to the project with 1 table called
LogEntries containing 2 columns: LogEntryID (int, auto inc) and
LogEntryData (nvarchar MAX)

I am running some simple LINQ code:
using (LogEntryDataContext db = new LogEntryDataContext())
{
LogEntry log = new LogEntry();
log.LogEntryData = data; //variable passed in

db.LogEntries.InsertOnSubmit(log);
db.SubmitChanges();
}

All runs perfect with no errors but the table never seems to contain any
new rows??

I am stumped as I get no errors? Is there something I am overlooking?

Thanks

Chev
Dec 11 '07 #3
Chevron Boyde wrote:
Ok I managed to solve the problem. Great waste of 3 hours!

When you add a sql express db to your project to uses AttachDbFilename
to point to the file in you project dir.
When you debug all the relevant files including the DB are copied to the
debug\bin folder. All updates are performed against this db not the db
orginally added. You should set the Copy To Output Directory property of
the file to Copy Never if you want to keep the file in your project.

I prefer adding the connection to the existing DB file and NOT adding
the db to the project.

More resources here:
http://briannoyes.net/PermaLink.aspx...f-aeeef64c4ed1

http://www.msdner.com/dev-archive/16/19-158-169725.shtm

Chev
I got bitten by exactly the same scenario yesterday - you're not the
only one!
Dec 11 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: MP | last post by:
ok - I have no idea what's doing on. In a nutshell I am doing a SQL insert in a Access database from PHP but am getting an error. Here is the code: // PHP db connection $db =...
1
by: Kent Wolf | last post by:
I have some code that worked just fine in Access 97 with Word 97 in Windows NT 4.0. We upgraded one of our OS's to Windows XP. Now, the code won't work. I got an error that said something...
5
by: darrel | last post by:
I'm still a bit stumped on how to load a usercontrol, and then pass a property value (or variable value) to it. Here's what I'm using to load the UC: localCUstomControl.ascx.vb...
8
by: Gary | last post by:
I'm using an Act database. I was stuck on this a year ago and am still having trouble. I have three bits of code like so : - act.CActAppObj objACT = new act.CActAppObj(); act.CAIBaseView...
3
by: Randy Magruder | last post by:
Hi all, I hope someone here can diagnose what I'm seeing because I'm stumped. I have an asp.net 1.1 application with a login page. I have loaded up the Page_Load( ) with trace messages and...
1
by: slamtart | last post by:
Hi everyone, Stumped for awhile with this one. Not sure what to do next. Basically, I have a laptop computer which I use for work. Prior to around May of this year, there's no trick to...
1
by: Sallana | last post by:
Hello guys. My name is Lynne and I am currently trying to build a website for a game that I play online called Exodus. This is the page --> http://exodus.mudmagic.com Immediately you can...
4
by: Gaisgeil | last post by:
Alright, I guess I'm stumped. I've been working on this for a while now and can't seem to figure it out. I'll post two screenshots to help explain the problem. The first image below is a webpage I'm...
5
by: Kardon Coupé | last post by:
Dear All, I'm bemused, I'm moving an application I've written from VB6 into VS2005, and I'm getting all the fundamentals over before I delve into the hard part, like getting the forms layout...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.