Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to make a connection to a SQL Compact server 4

Status
Not open for further replies.

44nato44

Programmer
Dec 12, 2008
115
NL
Hi

I have installed a SQL compact server 4 and cannot get a connection string to work with it.

I looked here but could not get any to work (I probably am doing something wrong)

The code below gives this error in the iis log : |5|80004005|- 80

I hope somebody can help ? :(

<%
Set Cnxn = CreateObject("ADODB.Connection")
Set cmd = CreateObject("ADODB.Command")
strCnxn = "Provider=Microsoft.SQLSERVER.CE.OLEDB.4.0;Data Source=E:\Migrate to Task Manager\TriActis\TaskManager.sdf;ssce:database password=Secret"
Cnxn.Open strCnxn
cmd.ActiveConnection = Cnxn
cmd.CommandText = "SELECT * FROM tblCompany"
While Not pRS.EOF
WScript.Echo pRS(0)
pRS.MoveNext
wend
%>
 
Try it without the provider part: just the data source.
 
Then I get this error : 6|80004005|[Microsoft][ODBC_Driver_Manager]_Data_source_name_not_found_and_no_default_driver_specified 80

With this line : strCnxn = "Data Source=c:\TaskManager.sdf;ssce:database password=Entity48*
 
Looks like it needs a driver. Open a cmd prompt, type odbccp32.cpl. Wait for the ODBC Data Source Administrator dialog to pop up. This will be in the User, System or File DSN tab. Look for the line that says (*.sdf). The part in the driver column is the driver string. Add

Driver=<driver string>;

to your connection string.
 
I am not able to find odbccp32.cpl .. I am on Windows 7
 
Not sure what it is called on Windows 7 but there is another way. Click on Start/Help and Support

In the dialog box, type odbc and click on the magnifying glass

Expand How do I open the ODBC Data Source Administrator
Click on Click to open ODBC Data Source Administrator
 
Just found out: it is called

odbcad32.exe
 
Was not able to find anything with sdf and I tried to set up another datasource with my database but it would not let me. It was not able to open the database it said.

It will give me two options to connect to the DB windows or SQL.. but the compact databases only have a password.

Not sure if I am running the wrong way or what I might be doing wrong ?
 
I've just installed it. Try

Driver=SQL Server
 
Sorry - just reread your title. I was using 2005. I'll try installing 4.0 and see what happens.
 
Sorry for misleading you. I thought there was an ODBC driver for SSCE but it appears there is only one for SS but not for SSCE. Try this. Put the following in a file called sqtest.vbs
Code:
Set Cnxn = CreateObject("ADODB.Connection") 
strCnxn = "Provider=Microsoft.SQLSERVER.CE.OLEDB.4.0;Data Source=E:\Migrate to Task Manager\TriActis\TaskManager.sdf;ssce:database password=Secret"
WScript.echo strCnxn
Cnxn.Open strCnxn 
WScript.echo "connection successful"
cmd.ActiveConnection = Cnxn 
set pRS = Cnxn.Execute("SELECT * FROM tblCompany")
While Not pRS.EOF 
   WScript.Echo pRS(0) 
   pRS.MoveNext 
wend
Run it using

cscript sqtest.vbs

It will probably fail after the connection string with an error. This time it will tell you what the error is in words instead of numbers.
 
Thanks so far.. now I get

Micosoft SQL Server Compace OLE DB Provider: Unspecified error


Does not say much....at least not to me :)

 
At a guess it is something to do with the password.

1) Can you create a DB without a password. Then try connecting without a password. That should work and prove that your installation is OK.

2) Then try your original DB without a password. Do you get something like

Microsoft SQL Server Compact OLE DB Provider: Authentication failed. [,,,,,]

 
Are you trying to open a database created with 3.5 with 4.0? That will normally give an unspecified error.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top