DataAdapter not working in VS2005

G

Guest

Hi,
I tried to use DataAdapter to access an .sdf file (SQL Mobile Database File).
This is the Code

using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Data.SqlServerCe;

DataTable dt = new DataTable();
SqlCeConnection Conn = new
SqlCeConnection("DataSource=\\ProgramFiles\\DbTest\\ssss.sdf");
Conn.Open();
SqlCeCommand sqlCmd = Conn.CreateCommand();
sqlCmd.CommandText = "Select * from MembershipData";
SqlCeDataAdapter da = new SqlCeDataAdapter("SELECT * FROM Users", Conn);
da.Fill(dt);

VS2005 Gave me the following errors.

Error 1: The type 'System.Data.Common.DbDataAdapter' is defined in an
assembly that is not referenced. You must add a reference to assembly
'System.Data.Common, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=969db8053d3322ac, Retargetable=Yes'.

Error 2: 'System.Data.SqlServerCe.SqlCeDataAdapter' does not contain a
definition for 'Fill'

Can some one tell me what is the problem with my code.
 
I

Ilya Tumanov [MS]

If that's NETCF V2 project you have a reference to incorrect version of
System.Data.SqlServerCe.dll (it's from SQL CE 2.0).

Please remove it and add reference to SQL Mobile DLL instead. If that's
NETCF V1 project add a reference to System. Data.Common.dll.


--
Best regards,


Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).
 
G

Guest

I am referencing the Dll from the below path "D:\program files\Microsoft SQL
Server 2005 Mobile Edition\Device\Client\v2.0". where i have installed
"SqlMobile30DeviceSdkENU.msi"

I then added reference to System.Data.Common.dll then it compiled but is
giving Run time exception "Missing Method Exception"

if this is the wrong Dll please tell me from where i can get the correct
Dll. i have already tried all the Dlls present on my machine.
 
I

Ilya Tumanov [MS]

Location you've mentioned contains SQL Client, not SQL CE/Mobile.



Correct location would be "<Your installation path>\SQL
Server\Mobile\v2.0\System.Data.SqlServerCe.dll" for NETCF V1 project (you
have to reference System.Data.Common.dll).

For NETCF V2 project you need to use "<Your installation path>\SQL
Server\Mobile\v3.0\System.Data.SqlServerCe.dll", in that case you should not
reference System.Data.Common.dll.



You would need to install SQL CE or Mobile CAB on to your device; correct
version depends on your project (NETCF V1 or V2 - you did not mention which
one it is.).

Keep in mind SQL CE is not supported on SP 2003 if that's your platform (you
also did not mention which platform you're developing for.).



--
Best regards,


Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).
 

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