public void Dispose()
{
if (this.connection != null)
{
this.connection.Dispose();
}
}
// ...
}
This only happens when I'm calling Application.Exit(); and Dispose is called through the destructor of the DatabaseManager class. When I'm disposing the connection during normal work the call works as intended. BTW I'm using SQL Server Mobile 3.0.5214.0 on a PPC 2003 AKU2 (Symbol PPT8846 industrial device).
I've got an application uses a WPF GUI, is built in VS2008 final, targets .Net Framework 3.5, and uses a Sql Ce 3.5 database for local storage. After a specific WPF window is rebound the application hangs. Hitting pause on the debugger reveals the offending method is a call to SqlCeConnection.Dispose(). Via Reflector I can see this method calls SqlCeConnection+ObjectLifeTimeTracker.Close() which in turn calls GC.WaitForPendingFinalizers(). Within WPF there are some objects (specifically TextBox) which need to have their resources freed on the main application thread. The finalizer thread is waiting on the main application thread, which is in turn waiting on the finalizer thread, resulting in a deadlock.
You can see some additional discussion of the topic including our temporary resolution in this thread.
My question is why is there a call to GC.WaitForPendingFinalizers() buried within the SqlCeConnection.Dispose() call tree?
I know that with traditional SQL systems, it is important to only open connections to a sql server when they are needed. However, since there is no "server" in mobile apps, is it bad practice to leave one open throughout the duration of an application?
The application is going to be constantly reading and writing to the data tables and it seems like it might be a good idea to leave it open.
We have an application that is built with WPF/.net 3.5 and leverages LINQ to SQL. Everything runs as expected when our application connects to MS SQL Server 2005. We have made a SQL CE version of our database using the Microsoft SYNC framework, and SQLMetal.exe to generate our .dbml.
The issue we are running into is that our application hangs while our LINQ to SQL objects are delay loading an EntitySet at random places throughout our code. After futher looking into the issue, and testing our published application on various workstations, we have discovered that the application does work on one computer that has SQL CE version 3.05.5365.0000. It does not however work on any computers that have SQL CE version 3.05.5386.0000.
We are logging the SQL queries that the LINQ to SQL is generating and when we execute them in the the Visual Studio 2008 Query Analyzer, they run successfully.
Any ideas are appreciated as we have hit a dead end.
I have a trigger on a table which when I do a direct update to throught QA seems to work fine. When a user developed application updates the record it locks their screen and record. I can't see where it could be causing it, but I am pasting it below. Any thoughts/comments greatly appreciated
CREATE TRIGGER tr_Patient_Updt2 ON patient_ FOR UPDATE AS if update(df_last_cholestero) begin declare @tstyears int declare @tdate datetime declare @sdate datetime declare @bdate datetime declare @ptage int declare @actid varchar(12)
select @bdate = convert(datetime,df_last_cholestero,101), @actid = account_id from inserted select @ptage = dbo.GetAge(convert(datetime,patient.Date_Of_Birth, 101), GETDATE()) from patient where patient.account_id = @actid select @sdate = convert(datetime,patient.Date_Of_Birth,101) from patient where patient.account_id = @actid select @tstyears = datediff(month,@bdate,getdate())
if @ptage between 18 and 65 begin transaction begin
if @tstyears < 12 begin set @ptage = @ptage + 5 set @sdate = DATEADD(year, @ptage, @sdate) update patient_ set df_next_cholestero = convert(char(08),@sdate,112) where patient_.account_id = @actid end
else if @tstyears >= 12 and @tstyears < 24 begin set @ptage = @ptage + 4 set @sdate = DATEADD(year, @ptage, @sdate) update patient_ set df_next_cholestero = convert(char(08),@sdate,112) where patient_.account_id = @actid end
else if @tstyears >= 24 and @tstyears < 36 begin set @ptage = @ptage + 3 set @sdate = DATEADD(year, @ptage, @sdate) update patient_ set df_next_cholestero = convert(char(08),@sdate,112) where patient_.account_id = @actid end
else if @tstyears >= 36 and @tstyears < 48 begin set @ptage = @ptage + 2 set @sdate = DATEADD(year, @ptage, @sdate) update patient_ set df_next_cholestero = convert(char(08),@sdate,112) where patient_.account_id = @actid end
if @tstyears > 48 begin set @ptage = @ptage + 1 set @sdate = DATEADD(year, @ptage, @sdate) update patient_ set df_next_cholestero = convert(char(08),@sdate,112) where patient_.account_id = @actid end
I have a .Net application which invokes an stored procedure (SQL Server 2005 Express installed on the same machine). When the stored procedure is called the first time, the application hangs because the sp never ends execution and the application's process has to be killed. But when the application is executed again, the sp runs as expected. What could be happening?
The stored procedure references remote tables by means of synonyms. If the Management Studio is used instead, the sp never ends execution when invoked the first time, but the query can be cancelled.
Now, if the sp is invoked first in the Management Studio first and then by the application, this does not hang (the sp executes as expected).
Hi! I am developing a CF 2.0 application for WM 6.0. In the application I'm doing a replication between a Sql Server 2005 database and a Sql Server 2005 Compact Edition database. When I'm trying to syncronize the databases for the first time, e.g., creating a new database with AddSubscription(AddOption.CreateDatabase)I cannot do a save afterwards the synchronization procedure. The synchronization works just fine and I get the right data to my device and so, but when I try to a save, the database hangs doing the commit().
If I'm on the otherhand restarts the application and then do a ReinitializeSubscription(true), e.g., doesn't not create a new database with AddSubscription(AddOption.CreateDatabase), and calls Synchronize(), everything works just fine. Anyone who has an explanation of this? (I do a Dispose() each time).
Given the following code:System.Data.SqlClient.SqlCommand sc = new System.Data.SqlClient.SqlCommand();sc.CommandText = "MySP";sc.CommandType = System.Data.CommandType.StoredProcedure;sc.Connection = new System.Data.SqlClient.SqlConnection("MyConnectionString"); sc.Connection.Open();sc.ExecuteNonQuery(); sc.Connection.Close();sc.Connection.Dispose();sc.Dispose();Is the call to sc.Connection.Dispose() necessary?J
I have an Execute SQL Task that returns a dataset to variable DfltValData. A dataflow follows that with a script component that access that dataset (read only variable) (see code below) and everything is fine. Now, after that, there's another dataflow with a script component, with the same code as below, trying to access DfltValData. Here is where the problem is, the DfltValData object does not contains any row. Whats happening and how to solve this?
Thanks!
Dim olead As New Data.OleDb.OleDbDataAdapter Dim dt As New Data.DataTable Dim row As System.Data.DataRow
i am using visual web developer 2005 and SQL Express 2005 with VB as the code behindi am using the following code to update the database table Dim update As New SqlDataSource() update.ConnectionString = ConfigurationManager.ConnectionStrings("DatabaseConnectionString").ToString() update.UpdateCommandType = SqlDataSourceCommandType.Text update.UpdateCommand = "UPDATE orderdetail SET fromdesignstatus = 2 ,progresspercentage = 15 , fromdesignlink = '" + designlink + "' WHERE order_id =" + ordersid.ToString() update.Update() update.Dispose() update = Nothing i am using update.Dispose() and update = nothing to release the memoryis it really necessary to use both the commandsif not , in my case which one is enough and what is the reasonplease help me
After making several hundred queries against a SQL CE 2.0 database (through NetCF/ADO.NET), I begin getting a SqlCeException: "Not enough storage is available to complete this operation."
Microsoft speaks to this situation in the following hotfix: http://support.microsoft.com/?kbid=827837
When I contacted them to receive the hotfixed ssce20.dll, they described the problem as SqlCeDataReader and SqlCeDataAdapter not releasing their memory resources after they went out of scope. In addition to using the hotfixed binary, they also advised me to call SqlCeEngine.Dispose() after every query to force SQL CE to release resources, as shown in the "finally" block of the code below.
I have a couple of questions about this:
(1) Will this cause a lot of performance overhead for me, especially if my application makes frequent queries using the following code?
(2) Can a cache an instance of SqlCeEngine and call Dispose() on that cached instance repeatedly, so I can avoid having to instantiate a new SqlCeEngine each time?
What is exactly the recommended way of using a SqlCeConnection object in your application?
In all the examples I see (IBuySpyDelivery for example) it opens the connection object in the constructor and leaves it open most of the time until the class gets disposed.
Is that the way to do it? Or should you open and close the connection for each database action (insert/select/delete) you're doing on the local SQL Mobile database?
I'm a bit confused, but maybe I'm messing up the way of working on remote database servers with how it should be done on a local SQL Mobile db.
I am trying to implement a web service that creates and populates a SQL Mobile database file, then returns the created database to a mobile device as a byte array. The database size could be in excess of 500,000 rows, which is why I want to do as much of this preprocessing on the server before it gets to the mobile device. I can't use replication since I have to do some shaping of the data before I can use it on the mobile device.
Unfortunately, the web service is throwing the following exception when I try to instantiate a SqlCeConnection object:
"System.NotSupportedException: SQL Server Everywhere Edition is not intended for ASP.NET development."
Are there any suggestions as to how I can get around this potential limitation? If I refactor out the code that actually performs the SqlCe operations to a separate assembly, but still call that assembly from within the ASP.NET process, will I get the same error?
I know that you can work with Sql Mobile databases from the deskop, and I suppose I could invoke a console application to create the database, but that seems like such a hack.
Hi, there; I have a couple of issue that really frustrates me. I asked a similar question before but I haven't resolved it yet. My application was developed with VS2003, c#,CF1.0,Sp1.
I found that after my application runs for a couple of hours, my SqlCeDataAdapter.Fill() method throw exception "Error Code: 8007000E Message : Not enough storage is available to complete this operation.". I found a couple of threads on the website said that I have to dispose adapter object (including its command objects.) Yes, I did!!!. And I also dispose my SqlCeConnection before it is out of range and recreate it when I need it. See:http://www.tutorials-se.com/sqlserverce/Keeping-SqlCeConnection/
I also introduced hotfix from http://support.microsoft.com/Default.aspx?kbid=827837. It looks like I tried everything, but I still has this exception.
At the same time, From thread "http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=426640&SiteID=1", Mr. Ilya said "native DLL (e.g. bar code scanner API) " could cause AV (access violation) issue. Yes, my application is running on Symbol 9062B device which use barcode scanner API, sometimes application will have "0xc0000005" exception when it exists (not when it is running) A serious problem is that the laser randomly crash in the middle of the scanning without any exception. I am quite sure it is not code logic issue. This happens since I introduced two SqlCeConnections which point to two different .sdf files (run at background threads). My impression is that the memory or stack are corrupted for some reason.
Hopefully I make myself clear. So my question is: 1. Will Sp3 help this? (Of course I will do some test) 2. How can I know memory or stack are corrupted/How to trace.
Again, thanks Mr.Ilya, you do a great job here, you are really really helpful!
I'm having a problem where I am getting a "Permission denied" exception when I call Open on a SqlCeConnection object using SqlCE version 3.5. It does this when mode is set to Read Only in the connection string. Furthermore it does this on XP, but not Vista. Here is the connection string I'm building:
I am facing a problem with vb.net application which i created to connect with and sqlservermobile edition file (.sdf). while the connection is declared, its producing the error that "Exception from Hresult : 0x4007000B." and some inner exception error lines. i imported system.data.sqlceserver and added the references too.
but It is working in my one of the system. i tried the same in some other system,its not working. you frndz have any about this. I think the system is lacking some dll files. any body having an idea about this. pls help me out.
I am developing a program on Visual Basic 2005 to a pocket pc, I want to make the SQLceconnection but It says that the file doesnīt exists, I use this code:
I am trying to access my SQL Server database through SqlCeConnection:
cecon = new SqlCeConnection("Data Source=D:\D_Drive\csharppract\nddbpda\nddbpda\nddbpdadatabase.sdf");
cecon.Open();
I am getting the following error:
System.Data.SqlServerCe.SqlCeException was unhandled Message="The path is not valid. Check the directory for the database. [ Path = D:\D_Drive\csharppract\nddbpda\nddbpda\nddbpdadatabase.sdf ]" HResult=-2147467259 NativeError=25009 Source="SQL Server 2005 Mobile Edition ADO.NET Data Provider" StackTrace: at System.Data.SqlServerCe.SqlCeConnection.ProcessResults() at System.Data.SqlServerCe.SqlCeConnection.Open() at System.Data.SqlServerCe.SqlCeConnection.Open() at nddbpda.frmCeMain.frmCeMain_Load() at System.Windows.Forms.Form.OnLoad() at System.Windows.Forms.Form._SetVisibleNotify() at System.Windows.Forms.Control.set_Visible() at System.Windows.Forms.Application.Run() at nddbpda.Program.Main()
When I tried to get the path from which the database file is being accepted, I got a different path:
I am trying to access my SQL Server database through SqlCeConnection:
cecon = new SqlCeConnection("Data Source=D:\D_Drive\csharppract\nddbpda\nddbpda\nddbpdadatabase.sdf"); cecon.Open();
I am getting the following error:
System.Data.SqlServerCe.SqlCeException was unhandled Message="The path is not valid. Check the directory for the database. [ Path = D:\D_Drive\csharppract\nddbpda\nddbpda\nddbpdadatabase.sdf ]" HResult=-2147467259 NativeError=25009 Source="SQL Server 2005 Mobile Edition ADO.NET Data Provider" StackTrace: at System.Data.SqlServerCe.SqlCeConnection.ProcessResults() at System.Data.SqlServerCe.SqlCeConnection.Open() at System.Data.SqlServerCe.SqlCeConnection.Open() at nddbpda.frmCeMain.frmCeMain_Load() at System.Windows.Forms.Form.OnLoad() at System.Windows.Forms.Form._SetVisibleNotify() at System.Windows.Forms.Control.set_Visible() at System.Windows.Forms.Application.Run() at nddbpda.Program.Main()
When I tried to get the path from which the database file is being accepted, I got a different path:
I am writing an application using VB.Net 2005 for the Windows CE 5.0 device and it is connecting to a SQL Server 2005 Mobile Edition Database. The trouble I'm having is establishing a connection to a SQL Server Mobile database on the device.
Here is the code I am using:
Code Snippet Public gConnectionString As String = "Data Source=Program FilesMobAppMobDB.sdf;Persist Security Info=False;"
Code Snippet
Imports System.Data.SqlServerCe
Public Class DBManager
Public Shared gSQLCEConnection As SqlCeConnection
Public Shared Function OpenDB() As Boolean
If gSQLCEConnection IsNot Nothing Then
Throw New InvalidOperationException("Connection already open.") End If gSQLCEConnection = New SqlCeConnection(gConnectionString) Try
gSQLCEConnection.Open() 'Error occurs here Return True Catch ex As SqlCeException
MsgBox(ex.Message & vbCrLf & ex.HResult & vbCrLf & ex.NativeError & vbCrLf & ex.Source) Return False End Try End Function
In the immediate window I recieve the following messages:
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll
A first chance exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll
A first chance exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll
A first chance exception of type 'System.Data.SqlServerCe.SqlCeException' occurred in System.Data.SqlServerCe.dll
I believe that the first few lines are caused by the icons/pictures that I have included with my app, but the SqlCeException line occurs when the connection to the .SDF file is trying to be established.
Here is the exception output:
Message: "" (Blank) HResult: -2147024882 NativeError: 0 Source: SQL Server 2005 Mobile Edition ADO.NET Data Provider
Programs under Remove Programs on the PDA are: Microsoft .NET CF 2.0 ENU-String R... Microsoft .NET Compact Framework... Microsoft SQL Client Microsoft SQL Mobile 2005 Microsoft SQL Mobile 2005 [EN] Microsoft SQL Server 2005 Compact... Microsoft SQL Server 2005 Compact... Microsoft SQL Server 2005 Compact... Microsoft SQLCE 2.0 Microsoft SQLCE 2.0 Dev
Any ideas on what could be stopping this connection from being established? It was working before but all of a sudden just stopped. I have warm booted, cold booted, and rebuilt with no luck and also checked that SQL Query Analyzer is not running on the PDA and that the connection string is valid. The call to OpenDB occurs in the form_load of the startup object.
have SQL Server 2005 std edition SP1 installed on Windows 2003 Std edition .Configured Transactional (single Publisher and no clustered environment.) Replication past two months working fine, Now 1.Distrib.exe application err is coming.
Due to which my job is failing (Distributor to Subscriber). Iam attaching thw file. Thanks Sandeep
I posted a message about this yesterday but I have more info..
I have a server (SQL 7.0, sp2) that anywhere I connect to it through EM the EM hangs. I can drill down into the server and even get into the Security drop down but if I hit Databases to drill down or Management etc. It hangs.
I did profiler on this and another server. When I click the + by the Database folder I hang and get "TSQL:Batch Starting: exec sp_MSdbuseraccess N'db', N'%'" but never get a "TSQL:BatchCompleted" for that statement. (Where other working servers I do get the set of both start and completed)
Drilling into the Security tab runs the query: exec sp_MSDBUserpriv... etc.) and this one works..
Anyone have any info on: exec sp_MSdbuseraccess N'db', N'%'
I can't find anything in BOL, Microsoft KB, Technet etc.. Please Help as there are certain things I can't do without EM... THANKS!!!
I have been trying all day to install SQL 7.0 on an NT 4.0 SP6a server. It gets to the point where it wants to load MDAC and just goes out to lunch. No errors are generated and the rest of the system does not appear to be affected. However, the only way to end the install is to end task it. Has anyone run into this?
Some of my jobs hang at FTP step for several hours until some one kills the FTP (it's a perl process) on the box. Is there a way to find how much time a particular step of the job is executing? and know it by somehow if it's hanging at that step?? If we know this,I want to kill the perl process(FTP) on the box in an automated way whenever the job hangs! Any ideas welcome!! Thanks. :-)
Hi all - I'm having a problem with a dts job that I haven't run across before. The function of the job itself is pretty basic just moving data into a sql table using a few lookups and mappings. The job starts fine and gets to a status of 5000 records processed and just sits there. It's doesn't go into a 'not responding state' nor does it produce any error information in the error file I set up. Anyone have any thoughts on what might be happening? How to identify the specific record it may be hanging on? Help!! - this one is driving me nuts.
I'm running a pretty simply DTS just to pump some data into a table. Nothing fancy just a couple lookups and a couple columns being copied over. I get to 5000 records processed and the DTS just spins its wheels. It does not go into a 'not responding' state. There are no indexes on the table and the db size is plenty big so it is not reindexing or resizing the db at this point. Any ideas on how I can debug this one would be greatly appreciated.
I am having a problem importing data into SQL 7 from any type of source. I go through the whole import process no problem. When I click the finish button to start the import, nothing at all happens. Enterprise Manager and the DTS just hang and I must use crtl+alt+delete to end the program. Can anyone give me any suggestions as to what might be happening. Big Thanks in advance, I've been working on this for days.
I've run dbcc check commands on a 5Gig database which has 2 Gig of unallocated space, with no problems with the tables or database. However when i try to run dbcc shrinkfile ( on the DATA file ) from Query Analyser the command just runs indefinitely with no response.
I am having problems of my DTS package hanging when run through the sql server agent through a scheduled job. If I execute the job manually it runs fine? If I run the package manually it runs fine? Of course there is no way to actually tell what is being hung? Any ideas?
Hi everyone, I had to do a restore of a database from tape. I have the tape set to eject when it's complete, the tape ejects and the dialog box looks like the restore finishes fine. But when I look at the database after the restore it is still in the loading phase. So the restore never really took or looks like it hangs. Do you guys know why or how to fix this problem? Thanks in advance.
My client is using SQL Server 6.5 on NT 4.0. They have recently began to have their SQL server session freeze intermittently. I have determined that only users that are accessing one particular database are freezing which leads me to a locking problem. What is the best way to determine the locking problem (i.e. event logs, sp_lock, ....)?