使用vb.net应用程序从ApplicationData文件夹中检索sql数据库 [英] retrieve sql database from ApplicationData folder with vb.net application

查看:39
本文介绍了使用vb.net应用程序从ApplicationData文件夹中检索sql数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的vb.net应用程序需要一个数据库,所以我在我的applicationData文件夹上设置了sql数据库,如'C:\ Users \shani \ AppData \ Rooaming',我将连接字符串设置为'Data Source =。 \ SQLEXPRESS; AttachDbFilename = C:\Users\shani \ AppData \Roaming\test.mdf; Integrated Security = True; Connect Timeout = 30; User Instance = True'.everything正常工作

但问题是,如果我在任何其他计算机连接字符串上安装我的应用程序将出错。

我的应用程序如何从ApplicationData文件夹中检索sql数据库而不考虑计算机用户名

plz任何人回答....我被捕获

my vb.net application needs a database, so i set sql database on my applicationData folder like this 'C:\Users\shani\AppData\Roaming' and i set connection string as 'Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\shani\AppData\Roaming\test.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True'.everything works correctly
But the problem is, if i install my application on any other computer connection string will get wrong.
how can my application retrieve sql database from ApplicationData folder without considering computer username
plz anyone answer.... am traped

推荐答案

尝试使用DataDirectory - < br $>


Try using DataDirectory--

"Data Source=AdityaSahVer\\SQLEXPRESS; Integrated Security=True;"AttachDbFilename=|DataDirectory|\DbFileName.mdf;Initial Catalog=Shipment"


这篇关于使用vb.net应用程序从ApplicationData文件夹中检索sql数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆