Visual basic SQL database Connection String

92 Views Asked by At

Well I have this 2 connections strings

1st "Data Source=(LocalDB)\v11.0;AttachDbFilename='C:\Users\Cj\Documents\Visual Studio 2013\Projects\LS-Optical\LS-Optical\Database1.mdf';Integrated Security=True;Connect Timeout=30"

2nd "Data Source=(LocalDB)\v11.0;AttachDbFilename='|DataDirectory|\Database1.mdf';Integrated Security=True;Connect Timeout=30"

these 2 connect/open the database but the 1st one Commits/saves the data using the app the.Second one save it WHILE the program is RUNNING and losses all data inputed while app is runing when the app is closed(Rollbacks)

well ican use the first one but isnt it better if the connection string is dynamically change base on the app directory.

if this string is wrong any suggestions that actomatically detect directory? PS igot the 1st one on server explorer database properties..... the 2nd one is from when making dataSource/datasets....

This is a Windows Form

0

There are 0 best solutions below