C#使用SQL设置项目 [英] C# Setup Project with SQL
本文介绍了C#使用SQL设置项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨朋友们,
我正在尝试为我的项目制作一个安装文件。
我的连接字符串;
Hi friends ,
I am trying make a setup file for my project.
My connection string ;
con.ConnectionString = "Server=.\\SQLExpress;AttachDbFilename=|DataDirectory|mynewproject.mdf;Trusted_Connection=True"
创建安装文件后,我有一个exe文件。我安装此文件一切正常。我在我的程序(其中一个已安装)目录中看到了我的数据库。当我打开我的程序时,它给出了一个错误:我的程序找不到数据库。
我想,我必须更改我的连接字符串。但我不知道我的连接字符串应该是什么。
After create setup file , i have a exe file. I'm install this file everything is okay. I see my database in my programs ( which one is installed ) directory. When i open my program , its giving an error : database not found by my program.
I guess , i must be change my connection string. But i don't know what should be my connection string.
推荐答案
检查这一串。
自动安装SQL 2005 Express的.NET安装程序 [ ^ ]
< a href =http://www.codeproject.com/Articles/11493/Create-database-during-installation-of-a-NET-appli>在安装.NET应用程序期间创建数据库 - 版本2 [ ^ ]
部署应用程序和数据库 [ ^ ]
FYI
将SQL Server Express嵌入自定义应用程序 [ ^ ]
如何:使用应用程序部署SQL Server Compact 4.0数据库 [ ^ ]
如何在应用程序中嵌入SQL Server Express [ ^ ]
Check this bunch.
.NET Installer that Automatically Installs SQL 2005 Express[^]
Create database during installation of a .NET application - Version 2[^]
Deploy your Application and Database[^]
FYI
Embedding SQL Server Express into Custom Applications[^]
How to: Deploy a SQL Server Compact 4.0 Database with an Application[^]
How to Embed SQL Server Express in an Application[^]
Use full path for AttachDbFileName=e:\data\mynewproject.mdf
See more info
http://msdn.microsoft.com/en-us/library/ms247257(v=vs.100).ASPX
您可以使用SqlConnectionStringBuilder类动态创建数据库连接字符串。
查看此链接:
< a href =http://msdn.microsoft.com/pl-pl/library/system.data.sqlclient.sqlconnectionstringbuilder%28v=vs.110%29.aspx> http://msdn.microsoft.com/pl -pl / library / system.data.sqlclient.sqlconnectionstringbuilder%28v = vs.110%29.aspx [ ^ ]
You can dynamically create your DB Connection string using SqlConnectionStringBuilder class.
Look at this link:
http://msdn.microsoft.com/pl-pl/library/system.data.sqlclient.sqlconnectionstringbuilder%28v=vs.110%29.aspx[^]
这篇关于C#使用SQL设置项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文