Trouble defining remote settings for SQL CE

drew4663

Well-known member
Joined
May 3, 2007
Messages
62
Programming Experience
1-3
I am using SQLCE and Visual Studio 2008.

I followed this tutorial.
I am needing the database to reside on one computer and be accessed by others. I did a build and into a shared folder called "app". The ip address of the host computer is 192.168.2.4.

This doesn't work and even if it did it doesn't solve the issue of remote connection but it's weird it won't even recognize it.
VB.NET:
    Dim con As SqlCeConnection = New SqlCeConnection("Data Source=C:\Documents and Settings\Andrew\Desktop\app\Database1.sdf") 'This here, declares where the database is located
    Dim Clear As Double
    Dim myDA As SqlCeDataAdapter
    Dim myDataSet As DataSet
    Dim dt As New DataTable()

This doesn't work either.
VB.NET:
    Dim con As SqlCeConnection = New SqlCeConnection("Data Source=\\192.168.2.4\app\Database1.sdf") 'This here, declares where the database is located
    Dim Clear As Double
    Dim myDA As SqlCeDataAdapter
    Dim myDataSet As DataSet
    Dim dt As New DataTable()

The only error it shows is that that path does not exist. I also tried editing the app.config file as well.

This works when the destinations are as follows for the login form and the app.config file.
"Login Form"
VB.NET:
    Dim con As SqlCeConnection = New SqlCeConnection("Data Source=\Database1.sdf") 'This here, declares where the database is located
    Dim Clear As Double
    Dim myDA As SqlCeDataAdapter
    Dim myDataSet As DataSet
    Dim dt As New DataTable()

VB.NET:
    <connectionStrings>
        <add name="logintestapp.My.MySettings.Database1ConnectionString"
            connectionString="Data Source=|DataDirectory|\Database1.sdf"
            providerName="Microsoft.SqlServerCe.Client.3.5" />
    </connectionStrings>

I hope I have given enough information to receive help. If not let me know and I'll see what more I could give. Thanks.
 
I'm not really good with using network addresses.

Can windows explorer follow the path?

The reason the code for login works is probably because the database is located there.
This is going to sound stupid, but make sure that the Database1.sdf file is where you put it.
 
I got the path problem fixed. I needed the code to say this:

VB.NET:
Dim con As SqlCeConnection = New SqlCeConnection("Data Source=[B]\\\[/B]192.168.2.4\app\Database1.sdf")

Instead of:

VB.NET:
Dim con As SqlCeConnection = New SqlCeConnection("Data Source=[B]\\[/B]192.168.2.4\app\Database1.sdf")

I no longer get the message that the path isn't valid but I am unable to save data to the database. It just does nothing. It doesn't even get an error message. I am able to validate the data that was already in the database. So, it appears I have read rights just not write rights. ( sounds funny :D )

I never set any properties or users for the database because I have yet to install any kind of data manager for SQL CE.
 
If using unix, make sure the DB has 777 privileges. (can't spell that word)

If windows, make sure file isn't set as read only.
 
Issue Resolved

I found out that SQL CE doesn't allow the database to be shared across a network share. I tried every method including installing it on IIS. All I had to do to get it to work was use the workgroup computer name instead of IP address. I tested the app and at worked great.

:D Fully working registration and login.
 
Back
Top