How to make the application access the local database (BLL & DAL)

Asked

Viewed 52 times

0

I have this link made to access there is local database, which using the executable on the computer where I created the application works and can access the database.
PUBLIC DAL()
{
_Sqlconn = new Sqlconnection(@"Data Source=(Localdb) Mssqllocaldb;Attachdbfilename=" + System.Windows.Forms.Application.Startuppath + @" staff.mdf;Integrated Security=True;Connect Timeout=30");

    }

and my problem is that when I run the program on another computer from which it has not installed the visual studio it opens but does not find the database that is in the same folder as the executable.

pasta que se envia com o executavel e a base de dados

  • Try : _Sqlconn = new Sqlconnection(@"Data Source=(Localdb) v11.0;Attachdbfilename="+System.Windows.Forms.Application.Startuppath+@" staff.mdf;Integrated Security=True;Connect Timeout=30");

  • José Gomes thanks for the help but did not work with this change now nor access the database on the computer where it is to be created

  • back to the previous code then and go to the database to find the link to it and put here please

  • Data Source=(Localdb) Mssqllocaldb;Attachdbfilename=C: Users SOFIA Desktop INTERNSHIP Windowsformsapp1 Windowsformsapp1 bin Debug staff.mdf;Integrated Security=True;Connect Timeout=30

  • supposedly this link is well done. write again because vs sometimes has bugs

  • One of the reasons I think it doesn’t work is because the other computer doesn’t have any specific program to open the database

  • if you have visual studio installed you can open the database without problem. What version of visual studio was the project created in? And what’s with the pc you’re trying to run?

  • The version of the visual studio is 2017 and the goal is to pass the program to work to another computer that does not have the visual studio, the problem is that on the computer I want to pass that does not have the visual studio can not open the database to demonstrate and insert information in a datagrid view

  • it usually works in the same

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.