setup and deployment visual basic 2010, ms-access database not found after installation - database

im using MS-access as my database. I've already finished the project and it is working perfectly fine.
my database location while im still developing is in C:\Users\Users\documents and the other one located at C:\Users\Users\documents\visual studio 2010\projects\project1\project1\bin\debug
is bad to put the database at two different folder?
1st problem: now creating a setup and deployment project, i use setup wizard and checked all then build it. installation of setup is successful but when i try to run the program, it doesnt respond,
2nd problem: i cant see my 1st database located at program files, only the second one and maybe this is the cause of unresponsive app.
copying the debug files into other computer and copying manually my database to user\document which i have to change permission and the copied debug files runs well, but i have to create an installer. how to do it?
from my server explorer i was wondering there is only one database, yet my program works fine when running debug? reconnecting the unseen database would be a lot of work because it is my main database.

You should check the database which is connected to your project and the path which is associated.
Try Application.StartUpPath in your connection.

Related

VS2019 MVC Database solution won't work on a second machine

I had created a webpage with DB access which works perfectly well on the machine I develop it. However, when I copy everything across to another machine, it fails with an error message - cannot open database xxx requested by the login. I did copy everything including the database created in the development environment and put it in the same place as the development did. What other thing I had done wrong ? Please help. In addition, when I open the solution on another machine, I cannot see the database from the SQL Server Object Explorer like what I saw on the development machine.
Problem solved ! Need to copy the database and the log file across and the used the SQL Server Manager to attach the database to the right server. After that, everything just work !!

Publishing a VB.NET Application with SQL Express DB (using LocalDB)

I have written a VB.Net application that uses an SQL Express DB file containing a single table and a handful of stored procedures.
I have successfully built and exported the application to my VPS.
The problem comes when knowing what to do concerning the database file, there is a wealth of stuff online but not specifically to suit my needs.
I plan to use LocalDB on the VPS but being commandline - it is hard to know if the scripts that I have run have been successful after creating an instance , starting it... etc,
I want to keep installation requirements to an absolute minimum on my VPS machine and (in time other end users machines)... hence using LocalDB and not SQL Express
So, what do I have to do on the VPS to enable my application to connect to the database.. ? This was simple when it was Access - (supply the MDB file and run the AccessDatabaseEngine(redistributable) - job done)
The connection on my devt. machine runs as expected.
The connection string in my code is:
Const strSQLConnection As String = "Data Source= (localdb)\v11.0;Database=SoccerTrader;Trusted_Connection=True"
Can anyone help please.. this is driving me around the bend.. surely it cant be that difficult..?
===========================
I have found the following in an MSDN blog which says:
Database as a File: LocalDB connection strings support AttachDbFileName property that allows attaching a database file during the connection process. This lets developers work directly with databases instead of the database server. Assuming a database file (*.MDF file with the corresponding *.LDF file) is stored at “C:\MyData\Database1.mdf” the developer can start working with it by simply using the following connection string: “Data Source=(localdb)\v11.0;Integrated Security=true;AttachDbFileName=C:\MyData\Database1.mdf”.
================ ADDED 12th June =====================
OK, this is really bugging me now... I have read around this till it is coming out of my ears and nothing specifically seems to target what I am trying to do. All the blogs I read refer to installing / running SQL Server and changing permissions etc.
As I have mentioned I am using a VPS and propose to use LocalDB on the VPS to access a simple/small database file for a VB.Net application I am writing.
This is the story so far.
1) I have built a working prototype on my development PC and connected using SQL Express to a database file SoccerTrader.mdf - no problem.
In the Visual Studio Project properties I have added a requirement to the project that checks for SQL Server ..and if it is missing, installs it...
2) I install the project on the VPS and as expected SQL Server 2012 LocalDB is installed .... see here..
3) I have copied the SoccerTrader.MDF and SoccerTrader.LDF files into "C:\BESTBETSoftware\SoccerBot" on the VPS
4) for practical reasons given the problems I am having getting this to work, I have implemented an inputbox for me to specify the connection string when the application runs.... the connection strings I have used give the following...
1]: http://i.stack.imgur.com/i2tro.png
I have not changed any file permissions on the development PC and the database state is NOT read only....
So, the question is where do I go from here...? What have I missed.. why is it not working..?
I have managed to sort the problem.
Seemingly, the connection string I was using was OK. It was my error handling that wasnt 'clean' enough. It transpired the connection was being made on my VPS but when the application attempted to update the table , the directory I had created and put the MDF file into, would not permit write access.
I moved the MDF into the C:\Users\Public\Documents folder and all works as it should.
You have to specify the full path of the Db file with folder name/ip-address

Visual Studio Published Project Crashing when trying to access Database files

This is the biggest problem I've had with my project so far. Every time I try to publish it, I get hangups and crashes whenever the project tries to access a database file (which is fairly often).
I have two database objects, both created as part of my Visual Studio project under the main solution, as BUILDERDATA.mdf and CHARACTERS.mdf. When I access them during test builds, everything functions just fine. However, they always fail in the published project.
I get the feeling either they're not exporting correctly, or the act of publishing the project is breaking the connection strings, so I'm hoping someone can help me pinpoint the issue.
Under my project settings, I have a connection set up to each database. They're both Connection Strings, their scope is Application, and the value is this:
Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\BUILDERDATA.mdf;Integrated Security=True;Connect Timeout=30
Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\CHARACTERS.mdf;Integrated Security=True;Connect Timeout=30
Under Project Properties -> Publish -> Application Files, both databases and their log files are set to Data File (Auto) for Publish Status, Required for Download Group, and Include for Hash.
Under my Prerequisites, I have SQL Server 2012 Express LocalDB marked, as well as Microsoft .NET Framework 4. Part of my code uses .NET, so that's required anyway, and I included SQL Server Express so it can access the database files. However, 2012 is the newest version available for me to include, so I'm not sure if there's an issue with that version?
If there's anything else you guys would need to see, please let me know. I just want to get this figured out and fixed so I can have my friends start testing my program. :(

Cannot attach database to MVC project

In my MVC project I am unable to attach the instance of a local database to the project. So after i run into this situation specifiied in this question, I tried to attach the local database manually by adding a connection in the Data connections. But it gives me the following error.
What is the right approach to add the databse to my project so that I could execute the program without any database errors?
The project was executing properly before I moved the project to another location. Now I have again moved the project back to the old location.

SqlExpress Db Is in use by system

I have a strange problem that is reoccurring. My app is a MVC5 application using EF code first and SQLExpress. My solution uses 4 databases - 3 of which work without a problem. The fourth database is constantly 'acquired' by 'System'. Everyday for the last week when I boot up I have a problem.
When I run the app and the DatabaseInitializer runs I get this exception :
Cannot open database "databaseName" requested by the login. The login failed. Login failed for user 'Computer\UserName'.
Weird. I read some S.O. articels about changing permision, but that smells to me. This database shouldent be in someone elses domain in the first place! The other databases work fine !
So I go about deleting the database. I get this error.
Error deleting file 'database.mdf'. The process cannot access the file because it is being use by another process.
So I reboot and go to delete the database directly from the windows explorer.
The action can't be completed because the file is open in System
I was finally able to delete the file by running my PC in safe mode and deleting it there. Im not sure what the cause of this is. I am running SQL express and I don't see any SQL background services running.

Resources