Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 469131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:45:06+00:00 2026-05-12T23:45:06+00:00

I want to make a database for my mobile 6 cellphone app. What I

  • 0

I want to make a database for my mobile 6 cellphone app. What I did was in visual studios I went to my project name and right clicked on it, went to add -> add new item -> data -> choose datafile.

It created a database file called “AppDatabase1.sdf”

Now I want to connect to my database but I don’t know how what the connection string is since I see no app.config where I normally would expect it to be.

So I just have

 SqlCeConnection conn = new SqlCeConnection("Not sure what to put here");
 conn.Open();

When I click on the server explorer tab I see my database so I click on it. In the properties section it has something labeled “connection string” however it looks like the path to the actual file and when I run it in the emulator I get an error.

“The database file cannot be found.
Check the path to the database.”

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T23:45:06+00:00Added an answer on May 12, 2026 at 11:45 pm

    You don’t have to create the database outside your application. It is probably better if you had a fail-safe so that if the user accidentally deletes it or it does not exist, then you can re-create it easily. This is good for initial installations. The following code will do what you want (SQLCE/Mobile 2005 example):

    Private Sub ConnectToDB()
            If (File.Exists("\SystemCF\LPI\inventory.sdf")) Then
                Try
                    cn = New SqlCeConnection("Data Source=\SystemCF\LPI\inventory.sdf;Password=")
                    cn.Open()
                Catch ex As Exception
                    MessageBox.Show(ex.Message)
                End Try
    
            ElseIf (File.Exists("\UserCF\LPI\inventory.sdf")) Then
                Try
                    cn = New SqlCeConnection("Data Source=\UserCF\LPI\inventory.sdf;Password=")
                    cn.Open()
                Catch ex As Exception
                    MessageBox.Show(ex.Message)
                End Try
    
            Else
        Try
           If (Not (Directory.Exists("\SystemCF\LPI"))) Then
                    Directory.CreateDirectory("\SystemCF\LPI")
           End If
    
           Dim engine As New SqlCeEngine("Data Source=\SystemCF\LPI\inventory.sdf")
           engine.CreateDatabase()
    
           cn = New SqlCeConnection("Data Source=\SystemCF\LPI\inventory.sdf")
           cn.Open()
    
           Call dropAndCreateDatabase()
         Catch ex As Exception
           MessageBox.Show(ex.Message)
           MessageBox.Show("Unable to create database!", "Database Create Failed")
         End Try
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make a PHP database insert with jQuery. How do I add
I want to make custom select from the database table using Linq. We use
I want to make a code snippet database web application. Would the best way
I want to make searching on my database with hibernate in Java, how can
I want to make a view in a database via Java that has a
So I want to make sure all of my database / network operations are
I want to make sure that if any error occurs during the database processing
I want to make a Windows service that will access my database. My database
I'm creating a database application using ASP.NET and I want to make a Windows
I have a Abc field in the database and I want to make sure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.