0

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

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by thines01
0

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.

Edited by thines01: Removing inadvertent emoticons

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.