hi all ,
i am developing a project that uses sdf database and i want to connect to it using odbc driver.. recently i found that there is no odbc driver for sdf database. I also found we can use ADODB and ADOX with oledb to connect with sdf.. but the problem is i don't know the coding to connect .. does any one know the coding that i can use to connect with sdf database using C++...

Thanks in advance
vince

I have both VS2008 and VS2010 installed and I see a reference/assembly I can add called System.Data.SqlServerCe.

I added that to a VS2008 project (so I can use IntelliSense) and added the namespace:
using namespace System:: Data:: SqlServerCe; //spaces added to prevent emoticons

At that point, I could issue code like this:

int main(array<System::String ^> ^args)
{
          Console::WriteLine(L"Hello World");

	 try
	 {
		SqlCeConnection^ conn = gcnew SqlCeConnection(L"Data Source=|DataDirectory|\\dbTEST.sdf");
		conn->Open();
		conn->Close();
	 }
	 catch(Exception^ exc)
	 {
		 Console::WriteLine(exc->Message);
		 return 0;
	 }
    return 0;
}

To find the connect string, I cheated by creating a C# project where I can poke around a see the settings.

Also, I copied the .sdf into the current directory.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.