Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / DB Engine / SQL Server CE / July 2008

Tip: Looking for answers? Try searching our database.

Sql Server CE attmpted to read or write problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dieter - 09 Jul 2008 08:31 GMT
Hello

I have a sql compact database created on Windows Vista. This works fine .
When i copy tis database to a Windows XP with SP 3 machine and run my
program i get exceptions saying:

"Attempted to read or write protected memory. This is often an indication
that other memory is corrupt.

Is there a solution for tis problem?

kind regards
Dieter
Ginny Caughey MVP - 09 Jul 2008 14:58 GMT
Dieter,

What version of SQL CE is the database, and does it have a password?

Ginny Caughey
Device Application Development MVP

> Hello
>
[quoted text clipped - 9 lines]
> kind regards
> Dieter
Dieter - 09 Jul 2008 15:13 GMT
SQL Server Compact Edition 3.5 and there is no password on the database

kind regards
dieter
> Dieter,
>
[quoted text clipped - 16 lines]
>> kind regards
>> Dieter
Ginny Caughey MVP - 09 Jul 2008 15:31 GMT
Dieter,

The main thing that might be different between Vista and Xp that could
affect a SDF file that I can think of is that the collation sequence is
different. SDF files carry their sorting info with them, and the first time
they are opened on a computer with a different collation sequence than the
one they're created on, they automatically reindex themselves as needed.
Generally you don't even notice this behavior, so I'm not sure if it's
related to your problem or not. Is there anything at all "interesting" about
the SDF file? Do you get the same behavior with other SDF files? Do you have
the same problem if you create the SDF file on the Xp machine and then try
to open it on a Vista one?

Ginny

> SQL Server Compact Edition 3.5 and there is no password on the database
>
[quoted text clipped - 20 lines]
>>> kind regards
>>> Dieter
Dieter - 10 Jul 2008 10:03 GMT
the strange thing is, even when i create the database on my XP machine
(using C# and .NET code) , is still get the error when i want to insert a
record on the same machien

> Dieter,
>
[quoted text clipped - 35 lines]
>>>> kind regards
>>>> Dieter
Dieter - 10 Jul 2008 10:11 GMT
this is the complete exception
  at
System.Data.Common.UnsafeNativeMethods.ICommandWithParameters.SetParameterInfo(IntPtr
cParams, IntPtr[] rgParamOrdinals, tagDBPARAMBINDINFO[] rgParamBindInfo)
  at
System.Data.OleDb.OleDbCommand.ApplyParameterBindings(ICommandWithParameters
commandWithParameters, tagDBPARAMBINDINFO[] bindInfo)
  at System.Data.OleDb.OleDbCommand.CreateAccessor()
  at System.Data.OleDb.OleDbCommand.InitializeCommand(CommandBehavior
behavior, Boolean throwifnotsupported)
  at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior
behavior, Object& executeResult)
  at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method)
  at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()

> the strange thing is, even when i create the database on my XP machine
> (using C# and .NET code) , is still get the error when i want to insert a
[quoted text clipped - 39 lines]
>>>>> kind regards
>>>>> Dieter
Ginny Caughey MVP - 10 Jul 2008 11:38 GMT
Dieter,

That is strange. What does your code that inserts a record look like? Can
you reproduce the problem in a small sample that creates the database and
then inserts a row?

Ginny

> the strange thing is, even when i create the database on my XP machine
> (using C# and .NET code) , is still get the error when i want to insert a
[quoted text clipped - 39 lines]
>>>>> kind regards
>>>>> Dieter
Dieter - 10 Jul 2008 11:54 GMT
the code looks like this,

       public void InsertMultisysRole_DLL(int roleId,int dllId)
       {
           OleDbConnection con = null;
           OleDbCommand command = null;
           string conString =
ConfigurationSettings.AppSettings["conString"].ToString(); ;

           try
           {
               con = new OleDbConnection(conString);

               command = new OleDbCommand();
               command.Connection = con;
               command.CommandText = " INSERT INTO
MultisysRoleDLL(DLLId,MultisysRoleId) VALUES (?,?)";
               command.Parameters.Add(new OleDbParameter("DLLId", dllId));
               command.Parameters.Add(new OleDbParameter("MultisysRoleId",
roleId));
               con.Open();
               command.ExecuteNonQuery();

           }
           catch (Exception ex)
           {
               throw ex;
           }
           finally
           {
               if (con != null)
                   con.Close();
           }
       }

> Dieter,
>
[quoted text clipped - 47 lines]
>>>>>> kind regards
>>>>>> Dieter
Ginny Caughey MVP - 10 Jul 2008 12:10 GMT
Dieter,

Why are you using OleDb from C#? Using a SqlCeConnection will work better
for you.

Ginny

> the code looks like this,
>
[quoted text clipped - 83 lines]
>>>>>>> kind regards
>>>>>>> Dieter
Dieter - 10 Jul 2008 12:19 GMT
because the same code also has to work against a full sql server
> Dieter,
>
[quoted text clipped - 92 lines]
>>>>>>>> kind regards
>>>>>>>> Dieter
Ginny Caughey MVP - 10 Jul 2008 13:00 GMT
Dieter,

If you need to build factory classes, use IDbConnection for the interface
code, but use the server-specific classes for actually accessing the data.
This gives you the best of both worlds. While you can get OleDb to work for
SQL Server, the OleDb provider for SQL Compact is not a complete OleDb
implementation and I don't get the sense that will change in the future.

Ginny

> because the same code also has to work against a full sql server
>> Dieter,
[quoted text clipped - 94 lines]
>>>>>>>>> kind regards
>>>>>>>>> Dieter
Dieter - 10 Jul 2008 14:24 GMT
ok i will do that
thx for the help

> Dieter,
>
[quoted text clipped - 104 lines]
>>>>>>>>>> kind regards
>>>>>>>>>> Dieter
Dieter - 10 Jul 2008 11:58 GMT
even a small program cause this error
> Dieter,
>
[quoted text clipped - 47 lines]
>>>>>> kind regards
>>>>>> Dieter
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.