Weird SqlCE Hang Issue

R

Rodney

I'm having an issue where SQL CE hangs when trying to do an insert
after an RDA pull. I believe this code duplicates my problem in a very
scaled down implementation. This problem happens on both the emulator
and PPC 2003 SE devices. We are using CF 2.0 with Sql Compact Edition
3.1. We are not able to move to Sq3.5 at this point
 
R

Rodney

Sorry for the accidental first post...

I'm having an issue where SQL CE hangs when trying to do an insert
after an RDA pull. I believe this code duplicates my problem in a very
scaled down implementation. This problem happens on PPC 2003 SE
devices and emulator as well as WM 5.0 devices. We are using CF 2.0
with SQL Compact Edition 3.1. Unfortunately, we are not able to move
to SQL CE 3.5 at this point since it would require our customers to
move to SQL Server 2005 or greater. Any help with this problem is
appreciated.

Thanks

using System;
using System.Data.SqlServerCe;
using System.IO;
using System.Windows.Forms;

namespace RdaCrashTest2
{
static class Program
{
private const string SDF_FILEPATH = @"\Program Files
\RdaCrashTest2\DB.sdf";
private const string SDF_CONN_STR = @"Data Source=" + SDF_FILEPATH;

private const string RDA_URL = "http://10.1.3.152/sqlcesa30.dll";
private const string RDA_USER = "username";
private const string RDA_PASS = "password";
private const string RDA_CONN_STR = "Provider=sqloledb;" +
"Data Source=SqlSrv2005;" +
"Initial Catalog=AdventureWorks;" +
"Integrated Security=SSPI";

[MTAThread]
static void Main()
{
// Make sure we blow away the previous database
if( File.Exists( SDF_FILEPATH ) )
{
File.Delete( SDF_FILEPATH );
}

// Create the database
SqlCeEngine engine = new SqlCeEngine( SDF_CONN_STR );
engine.CreateDatabase();
engine.Dispose();

// Pull a table
SqlCeRemoteDataAccess remoteDataAccess = new SqlCeRemoteDataAccess(
RDA_URL, RDA_USER, RDA_PASS, SDF_CONN_STR );
string selectSQL = "SELECT PostalCode FROM
AdventureWorks.Person.Address";
remoteDataAccess.Pull( "ZipTable", selectSQL, RDA_CONN_STR );
remoteDataAccess.Dispose();

// Modify the data
string insertSql = "INSERT INTO ZipTable VALUES ('59101')";
SqlCeConnection connection = new SqlCeConnection( SDF_CONN_STR );
SqlCeCommand command = new SqlCeCommand( insertSql, connection );
connection.Open();
command.ExecuteNonQuery(); // <!-- Hangs or crashes application
connection.Close();
command.Dispose();

MessageBox.Show( "Action Complete" );
}
}
}
 
R

Rodney

Sorry for the accidental first post...

I'm having an issue where SQL CE hangs when trying to do an insert
after an RDA pull. I believe this code duplicates my problem in a very
scaled down implementation. This problem happens on PPC 2003 SE
devices and emulator as well as WM 5.0 devices. We are using CF 2.0
with SQL Compact Edition 3.1. Unfortunately, we are not able to move
to SQL CE 3.5 at this point since it would require our customers to
move to SQL Server 2005 or greater. Any help with this problem is
appreciated.

Thanks

using System;
using System.Data.SqlServerCe;
using System.IO;
using System.Windows.Forms;

namespace RdaCrashTest2
{
        static class Program
        {
                private const string SDF_FILEPATH = @"\Program Files
\RdaCrashTest2\DB.sdf";
                private const string SDF_CONN_STR = @"Data Source=" + SDF_FILEPATH;

                private const string RDA_URL = "http://10.1.3.152/sqlcesa30.dll";
                private const string RDA_USER = "username";
                private const string RDA_PASS = "password";
                private const string RDA_CONN_STR = "Provider=sqloledb;" +
                        "Data Source=SqlSrv2005;" +
                        "Initial Catalog=AdventureWorks;" +
                        "Integrated Security=SSPI";

                [MTAThread]
                static void Main()
                {
                        // Make sure we blow awaythe previous database
                        if( File.Exists( SDF_FILEPATH ) )
                        {
                                File.Delete( SDF_FILEPATH );
                        }

                        // Create the database
                        SqlCeEngine engine = new SqlCeEngine( SDF_CONN_STR );
                        engine.CreateDatabase();
                        engine.Dispose();

                        // Pull a table
                        SqlCeRemoteDataAccess remoteDataAccess = new SqlCeRemoteDataAccess(
                                RDA_URL, RDA_USER, RDA_PASS, SDF_CONN_STR );
                        string selectSQL = "SELECT PostalCode FROM
AdventureWorks.Person.Address";
                        remoteDataAccess.Pull( "ZipTable", selectSQL, RDA_CONN_STR );
                        remoteDataAccess.Dispose();

                        // Modify the data
                        string insertSql = "INSERT INTO ZipTable VALUES ('59101')";
                        SqlCeConnection connection = new SqlCeConnection( SDF_CONN_STR );
                        SqlCeCommand command = new SqlCeCommand( insertSql, connection );
                        connection.Open();
                        command.ExecuteNonQuery(); // <!-- Hangs or crashes application
                        connection.Close();
                        command.Dispose();

                        MessageBox.Show( "Action Complete" );
                }
        }

}

It seems that I can pick any table/column to recreate this problem.
So, I think that eliminates any PK/FK issues. I have even tried to
pull down complete tables which I think eliminate any index problems.
In addition I have found that if I do any data modifying SQL statement
before the RDA pull the issue goes away. For my test I created a dummy
table right before the rda pull and then the problem spot went through
without issues.
 
D

davebythesea

Hi Rodney,

I would personally add some Exception handling to see what Exception is
being thrown -

string insertSql = "INSERT INTO ZipTable VALUES ('59101')";

SqlCeConnection connection = new SqlCeConnection( SDF_CONN_STR );
SqlCeCommand command = new SqlCeCommand( insertSql, connection );

try
{
connection.Open();
command.ExecuteNonQuery(); // <!-- Hangs or crashes
application
}
catch (SqlCeException sx)
{
//MessageBox.Show(sx.Message);
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message);
}
finally
{
connection.Close();
command.Dispose();
}

cheers

Rodney said:
Sorry for the accidental first post...

I'm having an issue where SQL CE hangs when trying to do an insert
after an RDA pull. I believe this code duplicates my problem in a very
scaled down implementation. This problem happens on PPC 2003 SE
devices and emulator as well as WM 5.0 devices. We are using CF 2.0
with SQL Compact Edition 3.1. Unfortunately, we are not able to move
to SQL CE 3.5 at this point since it would require our customers to
move to SQL Server 2005 or greater. Any help with this problem is
appreciated.

Thanks

using System;
using System.Data.SqlServerCe;
using System.IO;
using System.Windows.Forms;

namespace RdaCrashTest2
{
static class Program
{
private const string SDF_FILEPATH = @"\Program Files
\RdaCrashTest2\DB.sdf";
private const string SDF_CONN_STR = @"Data Source=" + SDF_FILEPATH;

private const string RDA_URL = "http://10.1.3.152/sqlcesa30.dll";
private const string RDA_USER = "username";
private const string RDA_PASS = "password";
private const string RDA_CONN_STR = "Provider=sqloledb;" +
"Data Source=SqlSrv2005;" +
"Initial Catalog=AdventureWorks;" +
"Integrated Security=SSPI";

[MTAThread]
static void Main()
{
// Make sure we blow away the previous database
if( File.Exists( SDF_FILEPATH ) )
{
File.Delete( SDF_FILEPATH );
}

// Create the database
SqlCeEngine engine = new SqlCeEngine( SDF_CONN_STR );
engine.CreateDatabase();
engine.Dispose();

// Pull a table
SqlCeRemoteDataAccess remoteDataAccess = new SqlCeRemoteDataAccess(
RDA_URL, RDA_USER, RDA_PASS, SDF_CONN_STR );
string selectSQL = "SELECT PostalCode FROM
AdventureWorks.Person.Address";
remoteDataAccess.Pull( "ZipTable", selectSQL, RDA_CONN_STR );
remoteDataAccess.Dispose();

// Modify the data
string insertSql = "INSERT INTO ZipTable VALUES ('59101')";
SqlCeConnection connection = new SqlCeConnection( SDF_CONN_STR );
SqlCeCommand command = new SqlCeCommand( insertSql, connection );
connection.Open();
command.ExecuteNonQuery(); // <!-- Hangs or crashes application
connection.Close();
command.Dispose();

MessageBox.Show( "Action Complete" );
}
}

}

It seems that I can pick any table/column to recreate this problem.
So, I think that eliminates any PK/FK issues. I have even tried to
pull down complete tables which I think eliminate any index problems.
In addition I have found that if I do any data modifying SQL statement
before the RDA pull the issue goes away. For my test I created a dummy
table right before the rda pull and then the problem spot went through
without issues.
 
R

Rodney

Dave,

I have tried a try/catch, but unfortunately there is no exception
created. I have tried to using catch( Exception ),
catch( SqlException ), and the generic catch incase a non complaint
SLR exception sneaked through.

Thanks


Hi Rodney,

I would personally add some Exception handling to see what Exception is
being thrown -

string insertSql = "INSERT INTO ZipTable VALUES ('59101')";

SqlCeConnection connection = new SqlCeConnection( SDF_CONN_STR );
SqlCeCommand command = new SqlCeCommand( insertSql, connection );

try
{
connection.Open();
command.ExecuteNonQuery(); // <!-- Hangs or crashes
application
}
catch (SqlCeException sx)
{
//MessageBox.Show(sx.Message);
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message);
}
finally
{
connection.Close();
command.Dispose();
}

cheers

Rodney said:
Sorry for the accidental first post...

I'm having an issue where SQL CE hangs when trying to do an insert
after an RDA pull. I believe this code duplicates my problem in a very
scaled down implementation. This problem happens on PPC 2003 SE
devices and emulator as well as WM 5.0 devices. We are using CF 2.0
with SQL Compact Edition 3.1. Unfortunately, we are not able to move
to SQL CE 3.5 at this point since it would require our customers to
move to SQL Server 2005 or greater. Any help with this problem is
appreciated.

Thanks

using System;
using System.Data.SqlServerCe;
using System.IO;
using System.Windows.Forms;

namespace RdaCrashTest2
{
static class Program
{
private const string SDF_FILEPATH = @"\Program Files
\RdaCrashTest2\DB.sdf";
private const string SDF_CONN_STR = @"Data Source=" + SDF_FILEPATH;

private const string RDA_URL = "http://10.1.3.152/sqlcesa30.dll";
private const string RDA_USER = "username";
private const string RDA_PASS = "password";
private const string RDA_CONN_STR = "Provider=sqloledb;" +
"Data Source=SqlSrv2005;" +
"Initial Catalog=AdventureWorks;" +
"Integrated Security=SSPI";

[MTAThread]
static void Main()
{
// Make sure we blow away the previous database
if( File.Exists( SDF_FILEPATH ) )
{
File.Delete( SDF_FILEPATH );
}

// Create the database
SqlCeEngine engine = new SqlCeEngine( SDF_CONN_STR );
engine.CreateDatabase();
engine.Dispose();

// Pull a table
SqlCeRemoteDataAccess remoteDataAccess = new SqlCeRemoteDataAccess(
RDA_URL, RDA_USER, RDA_PASS, SDF_CONN_STR );
string selectSQL = "SELECT PostalCode FROM
AdventureWorks.Person.Address";
remoteDataAccess.Pull( "ZipTable", selectSQL, RDA_CONN_STR );
remoteDataAccess.Dispose();

// Modify the data
string insertSql = "INSERT INTO ZipTable VALUES ('59101')";
SqlCeConnection connection = new SqlCeConnection( SDF_CONN_STR );
SqlCeCommand command = new SqlCeCommand( insertSql, connection );
connection.Open();
command.ExecuteNonQuery(); // <!-- Hangs or crashes application
connection.Close();
command.Dispose();

MessageBox.Show( "Action Complete" );
}
}

}

It seems that I can pick any table/column to recreate this problem.
So, I think that eliminates any PK/FK issues. I have even tried to
pull down complete tables which I think eliminate any index problems.
In addition I have found that if I do any data modifying SQL statement
before the RDA pull the issue goes away. For my test I created a dummy
table right before the rda pull and then the problem spot went through
without issues.
 
R

Rodney

Dave,

I have tried a try/catch, but unfortunately there is no exception
created. I have tried to using catch( Exception ),
catch( SqlException ), and the generic catch incase a non complaint
SLR exception sneaked through.

Thanks
Hi Rodney,
I would personally add some Exception handling to see what Exception is
being thrown -
string insertSql = "INSERT INTO ZipTable VALUES ('59101')";
            SqlCeConnection connection = new SqlCeConnection( SDF_CONN_STR );
            SqlCeCommand command = new SqlCeCommand( insertSql, connection );
            try
            {
                connection.Open();
                command.ExecuteNonQuery(); // <!-- Hangs or crashes
application
            }
            catch (SqlCeException sx)
            {
                //MessageBox.Show(sx.Message);
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
            }
            finally
            {
                connection.Close();
                command.Dispose();
            }

Sorry for the accidental first post...
I'm having an issue where SQL CE hangs when trying to do an insert
after an RDA pull. I believe this code duplicates my problem in a very
scaled down implementation. This problem happens on PPC 2003 SE
devices and emulator as well as WM 5.0 devices. We are using CF 2.0
with SQL Compact Edition 3.1. Unfortunately, we are not able to move
to SQL CE 3.5 at this point since it would require our customers to
move to SQL Server 2005 or greater. Any help with this problem is
appreciated.
Thanks
using System;
using System.Data.SqlServerCe;
using System.IO;
using System.Windows.Forms;
namespace RdaCrashTest2
{
        static class Program
        {
                private const string SDF_FILEPATH = @"\Program Files
\RdaCrashTest2\DB.sdf";
                private const string SDF_CONN_STR = @"Data Source=" + SDF_FILEPATH;
                private const string RDA_URL = "http://10.1.3.152/sqlcesa30.dll";
                private const string RDA_USER = "username";
                private const string RDA_PASS = "password";
                private const string RDA_CONN_STR = "Provider=sqloledb;" +
                        "Data Source=SqlSrv2005;" +
                        "Initial Catalog=AdventureWorks;" +
                        "Integrated Security=SSPI";
                [MTAThread]
                static void Main()
                {
                        // Make sure we blow away the previous database
                        if( File.Exists( SDF_FILEPATH ) )
                        {
                                File.Delete( SDF_FILEPATH );
                        }
                        // Create the database
                        SqlCeEngine engine = new SqlCeEngine( SDF_CONN_STR );
                        engine.CreateDatabase();
                        engine.Dispose();
                        // Pull a table
                        SqlCeRemoteDataAccess remoteDataAccess = new SqlCeRemoteDataAccess(
                                RDA_URL, RDA_USER, RDA_PASS, SDF_CONN_STR );
                        string selectSQL = "SELECT PostalCode FROM
AdventureWorks.Person.Address";
                        remoteDataAccess.Pull( "ZipTable", selectSQL, RDA_CONN_STR );
                        remoteDataAccess.Dispose();
                        // Modify the data
                        string insertSql = "INSERT INTO ZipTable VALUES ('59101')";
                        SqlCeConnection connection = new SqlCeConnection( SDF_CONN_STR );
                        SqlCeCommand command = new SqlCeCommand( insertSql, connection );
                        connection.Open();
                        command.ExecuteNonQuery(); // <!-- Hangs or crashes application
                        connection.Close();
                        command.Dispose();
                        MessageBox.Show( "Action Complete" );
                }
        }
}
It seems that I can pick any table/column to recreate this problem.
So, I think that eliminates any PK/FK issues. I have even tried to
pull down complete tables which I think eliminate any index problems.
In addition I have found that if I do any data modifying SQL statement
before the RDA pull the issue goes away. For my test I created a dummy
table right before the rda pull and then the problem spot went through
without issues.

Last post fix: Non compliant *CLR* exception
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top