Database.dbf文件出错。 [英] Error with Database.dbf file.

查看:102
本文介绍了Database.dbf文件出错。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。

我需要独立构建(WinApp +数据库)以便在另一台PC上安装。

在我的PC上工作时我是导入数据库文件(.dbf)到我的Windows应用程序项目,它工作正常。

但是当在另一台PC上安装这个项目时,它确实无法正常工作并且出现此错误(请参阅下面的链接。)

https://www.dropbox.com/s/ztz5d1dobtgd1c9/error.png? dl = 0 [ ^ ]

我正在使用SQLServer 2012 Express



这是连接字符串。 C#(不行吗)

<前lang =c#> 静态 string directory = Path.GetDirectoryName(Application.ExecutablePath);
SqlConnection Con = new SqlConnection( 数据Source =(LocalDB)\\v11.0; AttachDbFilename = + directory + \ \Database.mdf; Integrated Security = True);



(* update)

这是连接字符串VB(这个连接字符串在另一台PC上工作)

是否可以转换为C#?

 公共 conStr  As  String =  数据源=。\SQLEXPRESS;& _ 
AttachDbFilename = | DataDirectory | \Database.mdf;& _
Integrated Security = True; User Instance = True

解决方案

找不到服务器或无法访问服务器



您认为这意味着什么?

查看您的数据源:(LocalDB)\\v11.0

这对开发机器来说很好,但在生产中它是非常非常不可能的。您需要有一个连接字符串,该字符串存储在某个描述的参数文件中,允许将其更改为可以在客户端找到的实际SQL Server实例。



我无法帮你弄清楚那是什么:安装你的应用程序时,这取决于你。


我必须在我的Visual Studio项目中创建Database.mdf使用下面的代码。

 SqlConnection Con =  new  SqlConnection( 数据源=。\SQLEXPRESS; AttachDbFilename = | DataDirectory | \Database.mdf; Integrated Security = True; UserInstance = True); 


Hello everyone.
I need to build stand alone (WinApp+Database) for install on another PC.
When work on my PC i'm import database file (.dbf) to my Windows Application project, it's work fine.
But when install this project on another PC it does'n work and get this error (see the link below.)
https://www.dropbox.com/s/ztz5d1dobtgd1c9/error.png?dl=0[^]
i'm using SQLServer 2012 Express

Here is connection String. C# (Does'n work)

static string directory = Path.GetDirectoryName(Application.ExecutablePath);
        SqlConnection Con = new SqlConnection("Data Source=(LocalDB)\\v11.0;AttachDbFilename=" + directory + "\\Database.mdf;Integrated Security=True");


(*update)
Here is Connection String VB (This connection string working on another PC)
Is It Possible to convert to C#?

Public conStr As String = "Data Source=.\SQLEXPRESS;" & _
        "AttachDbFilename=|DataDirectory|\Database.mdf;" & _
        "Integrated Security=True;User Instance=True"

解决方案

"The server was not found or was not accessible"

What do you think that means?
Look at your data source: (LocalDB)\\v11.0
That's fine for a development machine, but in production it is very, very unlikely to be right. You need to have a connections string that is stored in a parameter file of some description which allows it to be changed to address the actual SQL Server instance to be found at the client.

I can't help you work out what that is: that's down to you when you installed your application.


I have to create Database.mdf in my project on Visual Studio and use this code below.

SqlConnection Con = new SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;UserInstance=True");


这篇关于Database.dbf文件出错。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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