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

  • Home
  • SEARCH
  • 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 7989499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:46:10+00:00 2026-06-04T12:46:10+00:00

I am creating 2 projects that have the same database (it’s an MDF database).

  • 0

I am creating 2 projects that have the same database (it’s an MDF database). The first one is the map editor, and I use XNA 4 and Web Services to connect to it. The second one is the game itself and uses XNA 3.1 and Entity Data Model to connect database.

When I run the map editor and access the database, it runs properly. Bbut when I run the game and access the database, it shows an error “The underlying provider failed on Open”

I think the connection from the web service is not closed yet. But I don’t know where I should close the connection.

Here is my code from the web service:

public Map AddNewMap(string username, string mapName, int sizeX, int sizeY)
    {
        using (BaseModelDataContext context = new BaseModelDataContext())
        {
            Map newMap = new Map()
            {
                Username = username,
                Name = mapName,
                SizeX = sizeX,
                SizeY = sizeY,
                Upload_Date = DateTime.Now,
                Status = 0
            };

            context.Maps.InsertOnSubmit(newMap);
            context.SubmitChanges(System.Data.Linq.ConflictMode.FailOnFirstConflict);
            context.Dispose();
            return newMap;
        }
    }

EDIT:

Here is the entity data model code :

using (MazeEntities ent = new MazeEntities())
        {
            ent.Connection.Open();
            return (from map in ent.Map
                    select map).ToList<Map>();
        }

This code runs properly if I did not use the web service before. If I use the web service first, it shows an error at ent.Connection.Open();

Here is the inner exception:

Cannot open user default database. Login failed.\r\nLogin failed for user ‘erkape-PC\erkape’.

Connection string for web service :

connectionString=”Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\3DMapDatabase.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True”

Connection string for the game:

“metadata=res:///MazeDataModel.csdl|res:///MazeDataModel.ssdl|res://*/MazeDataModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\SQLEXPRESS;AttachDbFilename=D:\eRKaPe\DropBox\TA\Program\3D_Map_Editor\3DMapEditorServices\App_Data\3DMapDatabase.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True;MultipleActiveResultSets=True"” providerName=”System.Data.EntityClient” />

  • 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-06-04T12:46:12+00:00Added an answer on June 4, 2026 at 12:46 pm

    Finally I found a way to solve my problem after reading some articles.
    The connection from the web service doesn’t close automatically after I close the map editor. That is why I can’t access my database from the game.
    I have to change the connection string from both application, I set the User Instance to False. The game can access the database this way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently use visual studio 2008 for creating projects that can run on windows.
I've worked on projects that have very complex XML configuration, and one problem that's
I have an ARM project that I'm building with make. I'm creating the list
I have been busy in my project creating a webapp (in struts) that manages
Background: I'm creating a dashboard as a project and I have a query that
I have a project in which I'm accessing a MySql database on my web
I have (java) code that creates and populates tables in a derby database, using
I have built a WP7.1 application that uses a local database. I used sqlmetal
I'm involved in creating a web based business solution. The idea is that the
I have a C++ project that uses IBPP to access a firebird database. I

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.