none
sql connection error

    Question

  • I am getting following error:

    Error 1 The type 'System.Data.Common.DbConnection' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. C:\Documents and Settings\Adnan\My Documents\Visual Studio 2005\Projects\Mobile5\Mobile5\Form1.cs 20 4 Mobile5


    the line which caused problem is

    System.Data.SqlServerCe.SqlCeConnection conn = null;

    following are being used as reference


    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.IO;
    using System.Windows.Forms;
    using System.Data.SqlServerCe;
    using System.Data.SqlClient;

    PLease guide me
    Wednesday, August 03, 2005 4:58 AM

Answers

  • There's no mystery here, you have a reference to desktop assembly in CF application which is not allowed. Look at PublicKeyToken (PKT):

    Desktop's PKT: b77a5c561934e089 
    NETCF     PKT: 969DB8053D3322AC

    Friday, August 05, 2005 7:52 PM

All replies

  • Hi,

    I guess you'll have to manually add the reference to System.Data or System.Data.SqlServerCe.

    Procedure:
    1. Right click References in your Solution Explorer.
    2. Select Add Reference.
    3. Navigate and find System.Data or System.Data.SqlServerCe. Select Add.

    I was assuming that this would be added by default to your reference...

     

    cheers,

    Paul June A. Domag

    Wednesday, August 03, 2005 5:15 AM
  • dear paul

    thanks for reply

    Yes i am adding the SQLServerCE dll files,the System.DATA was added automatically when i created new WindowsMObile5 Smartphone project,its still keep giving the error

    can you guide the location of required dll files because the default dlls are not being accepted
    Wednesday, August 03, 2005 6:21 AM
  • Hi,

    Hmmm. This is puzzling. The required dll's that was included in the installation should be in the GAC. What VS version are you using? Could you create a small project that just access the database?

     

    cheers,

    Paul June A. Domag

    Thursday, August 04, 2005 1:17 AM
  • paul

    its weird,what i did that i started new project and instead of

    System.Data.SqlServerCe.SqlCeConnection conn = null;

    i wrote

    SqlCeConnection conn = null;

    and it compiled

    i coudn`t understand the mystery
    Thursday, August 04, 2005 4:22 AM
  • Hi,

     

    Could you report this to Product Feedback? Also, keep me posted on their reply...

     

     

    cheers,

    Paul June A. Domag

    Friday, August 05, 2005 2:29 AM
  • hi

    i coudn`t resolve the mystery,i wasn`t right in my earlier post,now even defining complete class scheme,its compiling perfectly,i dont have any clue why it wasn`t working earlier and why working now,all i did that i created new mobile project

    that`s it

    -adnan
    Friday, August 05, 2005 7:31 PM
  • There's no mystery here, you have a reference to desktop assembly in CF application which is not allowed. Look at PublicKeyToken (PKT):

    Desktop's PKT: b77a5c561934e089 
    NETCF     PKT: 969DB8053D3322AC

    Friday, August 05, 2005 7:52 PM
  • Where should I find correct file? I tried files under following locations and it's giving me same error...

    C:\Program Files\Microsoft Visual Studio 8\SmartDevices\SDK\SQL Server\Mobile\v2.0

    C:\Program Files\Microsoft Visual Studio 8\SmartDevices\SDK\SQL Server\Mobile\v3.0

    C:\Program Files\Microsoft Visual Studio 8\Common7\IDE

    C:\Program Files\Microsoft Visual Studio .NET 2003\CompactFrameworkSDK\v1.0.5000\Windows CE

    Thanks for help.
    Friday, August 26, 2005 4:10 AM
  • For NETCF V2 project correct SQL Mobile provider is:

    C:\Program Files\Microsoft Visual Studio 8\SmartDevices\SDK\SQL Server\Mobile\v3.0\System.Data.SqlServerCe.dll

    If your project was converted, you might want to create a new NETCF V2 project and add all files from the old one instead of using conversion.

    If you have some other DLLs in your project, make sure they are NETCF compatible.
    You can open them with ILDASM tool and check out references in manifest. Make sure PKT for framework assemblies is "96 9D B8 05 3D 33 22 AC". For example:

    .assembly extern mscorlib

    {

    .publickeytoken = (96 9D B8 05 3D 33 22 AC ) // ....=3".

    .ver 2:0:0:0

    }

    If you see another PKT, this DLL is not NETCF compatible.

    Friday, August 26, 2005 8:47 PM
  • Alright man, I'd like to have your email address. Please send me an email at lateshpatel@hotmail.com. I tried everything you mentioned and what other people have tried but, nothing seems to work.

    Thanks a lot.
    Friday, August 26, 2005 11:41 PM
  • My email is IlyaTum with addition of (at)microsoft.com.
    (Sorry I've to be cryptic - don't like spam).

     

    By the way, have you tried fresh NETCF V2 project with some line like this in it?

     

    SqlCeConnection conn = new SqlCeConnection();

     

    Can you compile and run any NETCF project?

    Saturday, August 27, 2005 12:49 AM
  • Hi! i wonder if someone solved this problem.

    I'm having this same problem.

    Thanks
    Wednesday, October 19, 2005 9:40 AM
  • This happened to me once.

    I made a reference to a somehow incorrect version of System.Data.SqlServerCe.dll

    Sunday, January 07, 2007 7:33 PM
  • Hi Adnan,

    I am facing the same problem as you were facing, how did you solve the problem, can you assist me from begining, since i am new to this platform. I am using Visual Studio 2005 with SP1 and also installed "Microsoft SQL Server Compact Edition" separately.Your reply will be great helpfull to me.

     

    Thanks in advance

    Amit

     

    Monday, January 15, 2007 1:19 PM
  • Hi,

    I have had the same problem after installing SQL Server Compact edition

    I get the error if I reference the path

    1.            C:\Program Files\Microsoft SQL Server Compact Edition\v3.1\System.Data.SqlServerCe.dll

    This reference has a file version of 3.0.5.300.00, but an Assembly version of 9.0.242.0

     

    I don't get the error if I use these specific references.

    These have a  file version of 3.0.5.300.00, but an Assembly version of 3.0.3600.0

    C:\Program Files\Microsoft SQL Server Compact Edition\v3.1\SDK\bin\wce500\System.Data.SqlServerCe.dll

    or

    C:\Program Files\Microsoft SQL Server Compact Edition\v3.1\SDK\bin\wce400\System.Data.SqlServerCe.dll

    I haven't tried them in actual code yet.

     

    Terry

     

     

    Monday, January 29, 2007 12:14 AM
  • The token key definitely shows that it's a reference to a desktop dll. Download the entire SQL Compact SDK (not just the runtime) and use the System.Data.SqlServerCe.dll that is located in the SDK\bin\wce500 folder of the SDK install location.
    Thursday, February 08, 2007 11:02 PM