6 Replies - 8922 Views - Last Post: 12 October 2010 - 08:53 AM Rate Topic: -----

#1 Striker9099  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 19-October 09

Deployment of a project that has a database file (.sdf)

Posted 10 October 2010 - 11:29 AM

Hey everyone,

I think I'm finally done with a stock management project I've been working on lately. It still needs some retouches but I won't bother with them for now. The problem is that I cannot get it to deploy properly. I'm using SQL CE as my database engine. This creates an sdf file which can be used as the database. When I deploy the application, then install it, this sdf file is not being created inside the installation directory and I keep getting an exception saying the database file was not found everytime I run the exe file.

I'm using a Setup Project inside my Solution and I did not do anything to it except editing some of the properties (author, title...etc). Do I have to do anything else to have the sdf database file included in the deployed version?

Thanks in advance!

Is This A Good Question/Topic? 0
  • +

Replies To: Deployment of a project that has a database file (.sdf)

#2 JackOfAllTrades  Icon User is online

  • Saucy!
  • member icon

Reputation: 5954
  • View blog
  • Posts: 23,221
  • Joined: 23-August 08

Re: Deployment of a project that has a database file (.sdf)

Posted 10 October 2010 - 05:25 PM

Well yeah, you need to add any collateral files to the setup project as well. Right-click the Project, choose Add...then File.
Was This Post Helpful? 0
  • +
  • -

#3 Striker9099  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 19-October 09

Re: Deployment of a project that has a database file (.sdf)

Posted 10 October 2010 - 11:31 PM

View PostJackOfAllTrades, on 10 October 2010 - 04:25 PM, said:

Well yeah, you need to add any collateral files to the setup project as well. Right-click the Project, choose Add...then File.

Ok I did that, and here's the exception I keep getting whenever I try to add a category or a product:

Quote

System.Data.EntityException: The underlying provider failed on Open. ---> System.Data.SqlServerCe.SqlCeException: Access to the database file is not allowed. [ File name = C:\Program Files (x86)\Darwish Inc\HarbManager\HarbDB.sdf ]
at System.Data.SqlServerCe.SqlCeConnection.ProcessResults(Int32 hr)
at System.Data.SqlServerCe.SqlCeConnection.Open(Boolean silent)
at System.Data.SqlServerCe.SqlCeConnection.Open()
at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)
--- End of inner exception stack trace ---
at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)
at System.Data.EntityClient.EntityConnection.Open()
at System.Data.Objects.ObjectContext.EnsureConnection()
at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)
at HarbManager.Admin.AdminMain.AddCategoryBtn_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.onclick(EventArgs e)
at System.Windows.Forms.Button.onclick(EventArgs e)
at System.Windows.Forms.Button.onmouseup(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m)
at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


Also, whenever I run the application, I get the following exception:

Quote

System.ArgumentOutOfRangeException: InvalidArgument=Value of '-1' is not valid for 'index'.
Parameter name: index
at System.Windows.Forms.ComboBox.ObjectCollection.get_Item(Int32 index)
at HarbManager.MainForm.MainForm_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.onload(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m)
at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

I'm thinking that if I could find a solution for the first issue (database access), the later exception will be resolved as well, am I right?
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is online

  • Saucy!
  • member icon

Reputation: 5954
  • View blog
  • Posts: 23,221
  • Joined: 23-August 08

Re: Deployment of a project that has a database file (.sdf)

Posted 11 October 2010 - 04:32 AM

You know, when I get an error message the fix to which is not immediately obvious, I always choose to Google the error. Chances are you're not the first person to get it. So, Googling "Access to the database file is not allowed", look what the very first link brings up: http://social.msdn.m...e3-b77337560021
Was This Post Helpful? 0
  • +
  • -

#5 Striker9099  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 19-October 09

Re: Deployment of a project that has a database file (.sdf)

Posted 11 October 2010 - 06:31 AM

View PostJackOfAllTrades, on 11 October 2010 - 03:32 AM, said:

You know, when I get an error message the fix to which is not immediately obvious, I always choose to Google the error. Chances are you're not the first person to get it. So, Googling "Access to the database file is not allowed", look what the very first link brings up: http://social.msdn.m...e3-b77337560021

Ah thanks a bunch! I really should've done that before posting here. It's just that I kept getting all different kinds of exceptions until I finally stumbled on this one which got me really frustrated. Again, thanks for the help, much appreciated! :)
Was This Post Helpful? 0
  • +
  • -

#6 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4312
  • View blog
  • Posts: 7,467
  • Joined: 08-June 10

Re: Deployment of a project that has a database file (.sdf)

Posted 12 October 2010 - 06:04 AM

Call this an object lesson. It's not really well known, but the thing that separates experts from the average coder isn't always our experience or knowledge, it's frequently that we know how to google better. Or, more accurately, we know how to properly look for solutions to problems.

I don't know the answer to half the questions I answer on this forum until I research them. Am I doing anything the original posters couldn't? Not really. But that's part of what makes us good programmers is knowing how to find our own solutions.

Learn that, and you'll truly be ahead of the game.
Was This Post Helpful? 2
  • +
  • -

#7 Striker9099  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 19-October 09

Re: Deployment of a project that has a database file (.sdf)

Posted 12 October 2010 - 08:53 AM

View PostinsertAlias, on 12 October 2010 - 05:04 AM, said:

Call this an object lesson. It's not really well known, but the thing that separates experts from the average coder isn't always our experience or knowledge, it's frequently that we know how to google better. Or, more accurately, we know how to properly look for solutions to problems.

I don't know the answer to half the questions I answer on this forum until I research them. Am I doing anything the original posters couldn't? Not really. But that's part of what makes us good programmers is knowing how to find our own solutions.

Learn that, and you'll truly be ahead of the game.

Wisely said! I'll keep that in mind and hopefully that would make my development experience much more pleasurable from now on. I cannot say I'm an expert by any means (I'm still studying at the uni) but I try to work hard on my skill-set that should qualify me to become an expert in the near future. Knowing where to look and how to look for solutions is definitely a skill I should add to my arsenal.

Thanks again! :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1