Showing posts with label winform. Show all posts
Showing posts with label winform. Show all posts

Monday, March 19, 2012

Data corruption in ldf when debugging WinForm app

I'm trying to build my 1st WinForm app which uses SqlExpress and when I click Debug and test my app everything is fine (though occasionally I do get time out errors - but that's another question I guess), however I can't then debug the app again because I get the following error:

"The log scan number (34:410:82) passed to log scan in database '3D1D0C232D2C55B0EF6C455470CD3D4C_S\\VISUAL STUDIO 2005\\PROJECTS\\MYFIRSTAPP\\MYFIRSTAPP\\BIN\\DEBUG\\OTJDB.MDF' is not valid. This error may indicate data corruption or that the log file (.ldf) does not match the data file (.mdf). If this error occurred during replication, re-create the publication. Otherwise, restore from backup if the problem results in a failure during startup. \r\nAn error occurred during recovery, preventing the database '3D1D0C232D2C55B0EF6C455470CD3D4C_S\\VISUAL STUDIO 2005\\PROJECTS\\MYFIRSTAPP\\MYFIRSTAPP\\BIN\\DEBUG\\OTJDB.MDF' (database ID 5) from restarting. Diagnose the recovery errors and fix them, or restore from a known good backup. If errors are not corrected or expected, contact Technical Support.\r\nCannot open user default database. Login failed.\r\nLogin failed for user 'SQurreL\\Simon'."

I can't delete the ldf or mdb files in the debug\bin folder because they are in use, so I have to stop the SQLExpress service, kill the sqlserv.exe process, delete the ldf and mdb files, then restart the SQLExpress service and try again... which is beginning to get right on my nerves nowAngry

Can anyone help with my sanity please?

Hi ganseki,

I think the error message has claimed very clearly: " .....that the log file (.ldf) does not match the data file (.mdf)." If mdf file and the corresponding ldf file cannot match, we cannot open that database again--that's designed by microsoft. So, we need to "If this error occurred during replication, re-create the publication. Otherwise, restore from backup..".

I have to stop the SQLExpress service, kill the sqlserv.exe process, delete the ldf and mdb files, then restart the SQLExpress service and try again

I think what you did is right. So, does this error still occure after you did that? Also i'm curious about what you did to that database thru your application, that you get that error message.

Hope my suggestion helps

|||

Thanks for the reply.

Any idea why that is happening each time I debug the app? Or is it normal for WinForms development to have to jump through those hoops in order to test the changes.

It takes longer to stop the service, kill the process, delete the files and restart the service than to make a change to a column width in a datagridview, which if I then find is too narrow or too wide means I have to go through that whole process again just to check that changing the width from 150 to 100 isn't enough? This involves no change to the database, all that would have happened is a select to get the data for the grid, but it happens even without any database interaction - i.e. just opening the app (which starts with a blank page).

After debugging I click the close button on the form, the app closes and Visual Studio quits debug mode. I make changes (which can be as trivial as my illustration above) and then have to go through that routine. And that happens each and every time I want to debug.

It is driving meinsane
Is there something I should be doing differently to stop this from happening?

Thursday, March 8, 2012

data caching on SQL Server?

Suppose 40 winform clients of SQL Server(SS) 2005 request the same data (select * from sometable).

Is there any proxy service in SS or all clients will be queueing/competing for the same answer?

Hi,

I think its the dot net that do the caching not Sql server.

http://www.codeproject.com/csharp/webservicecache.asp

regards,

joey

|||

Different winform clients are on different machines with different .NET frameworks generally without any knowledge about each other connecting to one central MS SQL Server db?

So, each winform client may cache data to avoid repeting the request to SQL Server... according to your link. Or it is done by ASP.NET/IIS (for webforms)

But the question is about caching by SQL Server, to avoid the server to service the same results to different WINFORM clients.

Since SQL Server 2005 is integrated with .NET, it is quite logical to expect such proxy service from SQL Server or .NET framework whith which MSS2005 is integrated with, isn't it?


Is it available by MS SQL Server 2005? how it is called? or I should create it?

|||

hi,

you might want to create a 'view' or an 'indexed view'

if the query is not parameterized or a stored procedure if it is parameterized

if you're into a very fast performance i'll recommend index view though you

will be penalized for disk space.

if its is a stored procedure execution is cached not the the result .

the link i gave you was caching the data by having winforms to consume

a webservice which stores the cached dataset

regards,

joey

|||

joeydj , Thanks for your guidance

Having rephrased my doubt more concisely:
if ASP.NET server data webcontrols permit declarative specification for caching data (on server side), I do not see why winforms controls have not the ability to do the same, say, through one of MS SQL Server2005 configurable and built.in (web)sevice...

|||

In my question I really wanted to ask whether the MSSSdb engine needs to compute/execute data according query again (even according to compiled/cached plan) and whether it repeats I/O operations in order to to get the same data structures.

This is rather important to know in order to make decisions on where to customly cache (on server or client), when, for how long and how much data.

Reporting Services has cached reports.
Really(and obviously) there are data buffers in memory. Also one can explicitly place data structures into memory [1]

Code Snippet

--Use the pubs database USE pubs DECLARE @.dbid INTEGER SET @.dbid = DB_ID('pubs') --Determine id number for the dbo.authorstable DECLARE @.obid INTEGER SET @.obid = OBJECT_ID('dbo.authors') --Pin the dbo.authors table to memory DBCC PINTABLE (@.dbid,@.obid) GO

Though details how to control memory management are not very explicit in docs


[1]
Introduction into Caching in SQL Server 2000

http://www.extremeexperts.com/SQL/Articles/SQLCacheObjects.aspx

|||

Well, after all there is direct match to my question.

ADO.NET 2.0 (SQL Server 2005) supports

1)
server-side cursors

ExecuteResultSet of SqlResultSet

2)

Paging

ExecutePageReader(CommandBehavior.Default, nStartRow, nPageSize);

3)

Asynchronous execution of commands

4)

MARS - Multiple Result Sets

Saturday, February 25, 2012

Data access advise

Hi
vs2005/sql server2005. I have created a simple winform app by dragging a
table on a winform. I have used stored procedures for data access. I have
the following questions;
1. Using the default code generated by vs2005 for data access, how can I
trap record insertion to set some field values before the record is
inserted?
2. The default data access works nicely for insert in the main table. I need
to insert a detailed record for every record inserted in the main table. How
and where do I implement this second insert?
3. If I type a value in 'Company' field on the winform, when record is saved
the underlying table contains that same value in every field that has word
"company" in the fieldname such as CompanyType, CompanyAddress etc. Why is
that?
Thanks
RegardsYou may have better results posting to the *.windowsforms.databinding group.
"John S" <John@.nospam.infovis.co.uk> wrote in message
news:ujjYWH5rFHA.508@.TK2MSFTNGSA03.privatenews.microsoft.com...
> Hi
> vs2005/sql server2005. I have created a simple winform app by dragging a
> table on a winform. I have used stored procedures for data access. I have
> the following questions;
> 1. Using the default code generated by vs2005 for data access, how can I
> trap record insertion to set some field values before the record is
> inserted?
> 2. The default data access works nicely for insert in the main table. I
> need
> to insert a detailed record for every record inserted in the main table.
> How
> and where do I implement this second insert?
> 3. If I type a value in 'Company' field on the winform, when record is
> saved
> the underlying table contains that same value in every field that has word
> "company" in the fieldname such as CompanyType, CompanyAddress etc. Why is
> that?
> Thanks
> Regards
>
>

Data access advise

Hi
vs2005/sql server2005. I have created a simple winform app by dragging a
table on a winform. I have used stored procedures for data access. I have
the following questions;
1. Using the default code generated by vs2005 for data access, how can I
trap record insertion to set some field values before the record is
inserted?
2. The default data access works nicely for insert in the main table. I need
to insert a detailed record for every record inserted in the main table. How
and where do I implement this second insert?
3. If I type a value in 'Company' field on the winform, when record is saved
the underlying table contains that same value in every field that has word
"company" in the fieldname such as CompanyType, CompanyAddress etc. Why is
that?
Thanks
Regards
You may have better results posting to the *.windowsforms.databinding group.
"John S" <John@.nospam.infovis.co.uk> wrote in message
news:ujjYWH5rFHA.508@.TK2MSFTNGSA03.privatenews.mic rosoft.com...
> Hi
> vs2005/sql server2005. I have created a simple winform app by dragging a
> table on a winform. I have used stored procedures for data access. I have
> the following questions;
> 1. Using the default code generated by vs2005 for data access, how can I
> trap record insertion to set some field values before the record is
> inserted?
> 2. The default data access works nicely for insert in the main table. I
> need
> to insert a detailed record for every record inserted in the main table.
> How
> and where do I implement this second insert?
> 3. If I type a value in 'Company' field on the winform, when record is
> saved
> the underlying table contains that same value in every field that has word
> "company" in the fieldname such as CompanyType, CompanyAddress etc. Why is
> that?
> Thanks
> Regards
>
>

Friday, February 24, 2012

Data access advise

Hi
vs2005/sql server2005. I have created a simple winform app by dragging a
table on a winform. I have used stored procedures for data access. I have
the following questions;
1. Using the default code generated by vs2005 for data access, how can I
trap record insertion to set some field values before the record is
inserted?
2. The default data access works nicely for insert in the main table. I need
to insert a detailed record for every record inserted in the main table. How
and where do I implement this second insert?
3. If I type a value in 'Company' field on the winform, when record is saved
the underlying table contains that same value in every field that has word
"company" in the fieldname such as CompanyType, CompanyAddress etc. Why is
that?
Thanks
RegardsYou may have better results posting to the *.windowsforms.databinding group.
"John S" <John@.nospam.infovis.co.uk> wrote in message
news:ujjYWH5rFHA.508@.TK2MSFTNGSA03.privatenews.microsoft.com...
> Hi
> vs2005/sql server2005. I have created a simple winform app by dragging a
> table on a winform. I have used stored procedures for data access. I have
> the following questions;
> 1. Using the default code generated by vs2005 for data access, how can I
> trap record insertion to set some field values before the record is
> inserted?
> 2. The default data access works nicely for insert in the main table. I
> need
> to insert a detailed record for every record inserted in the main table.
> How
> and where do I implement this second insert?
> 3. If I type a value in 'Company' field on the winform, when record is
> saved
> the underlying table contains that same value in every field that has word
> "company" in the fieldname such as CompanyType, CompanyAddress etc. Why is
> that?
> Thanks
> Regards
>
>

Data access advise

Hi
vs2005/sql server2005. I have created a simple winform app by dragging a
table on a winform. I have used stored procedures for data access. I have
the following questions;
1. Using the default code generated by vs2005 for data access, how can I
trap record insertion to set some field values before the record is
inserted?
2. The default data access works nicely for insert in the main table. I need
to insert a detailed record for every record inserted in the main table. How
and where do I implement this second insert?
3. If I type a value in 'Company' field on the winform, when record is saved
the underlying table contains that same value in every field that has word
"company" in the fieldname such as CompanyType, CompanyAddress etc. Why is
that?
Thanks
RegardsYou may have better results posting to the *.windowsforms.databinding group.
"John S" <John@.nospam.infovis.co.uk> wrote in message
news:ujjYWH5rFHA.508@.TK2MSFTNGSA03.privatenews.microsoft.com...
> Hi
> vs2005/sql server2005. I have created a simple winform app by dragging a
> table on a winform. I have used stored procedures for data access. I have
> the following questions;
> 1. Using the default code generated by vs2005 for data access, how can I
> trap record insertion to set some field values before the record is
> inserted?
> 2. The default data access works nicely for insert in the main table. I
> need
> to insert a detailed record for every record inserted in the main table.
> How
> and where do I implement this second insert?
> 3. If I type a value in 'Company' field on the winform, when record is
> saved
> the underlying table contains that same value in every field that has word
> "company" in the fieldname such as CompanyType, CompanyAddress etc. Why is
> that?
> Thanks
> Regards
>
>