简体   繁体   English

如何在Visual Studio中创建一个已经存在的数据库?

[英]How to create an already existing database in Visual Studio?

I am trying to run an application that has been downloaded from GitHub. 我正在尝试运行从GitHub下载的应用程序。 The creator of the project provided usernames and passwords to log in for the application. 项目的创建者提供了用于登录该应用程序的用户名和密码。 Whenever I try to log in, I get an error that says: 每当我尝试登录时,都会出现错误消息:

"System.Data.SqlClient.SqlException: 'Cannot open database "Library" requested by the login. The login failed. Login failed for user 'DESKTOP-CBKOJI6\\user\u0026#39;." “ System.Data.SqlClient.SqlException:'无法打开登录请求的数据库“库”。登录失败。用户'DESKTOP-CBKOJI6 \\ user'的登录失败。”

I tried doing the following but I still keep getting the same error 我尝试执行以下操作,但仍然出现相同的错误

Cannot open database "test" requested by the login. 无法打开登录请求的数据库“测试”。 The login failed. 登录失败。 Login failed for user 'xyz\\ASPNET' 用户“ xyz \\ ASPNET”的登录失败

<connectionStrings>
name="DbConnection"
connectionString="Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=Library;Integrated Security=TrueConnect; Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False" />
</connectionStrings>

This is the database that is in the App.config 这是App.config中的数据库

The error I get is in this line of code: 我得到的错误是在以下代码行中:

con.Open();

EDIT 1: 编辑1:

Link for the project >> https://github.com/RuXeR97/Library 项目链接>> https://github.com/RuXeR97/Library

You have to actually create the database first... You can't log into it if it doesn't exist. 您必须首先实际创建数据库...如果数据库不存在,则无法登录。

Did the download come with a database project (you can publish that through visual studio), or .sql files (you can run them in SQL Server Management Studio) to create the database first. 下载是否随数据库项目(您可以通过Visual Studio发布)一起提供,还是与.sql文件(您可以在SQL Server Management Studio中运行它们)一起首先创建数据库。

Maybe link to the github project so we can take a look? 也许链接到github项目,以便我们看看?

Data Source=(localdb)\MSSQLLocalDB;

According to this line of code, you are trying to log into a local database which is supposed to be created by yourself locally. 根据这一行代码,您正在尝试登录应该由您自己在本地创建的本地数据库。 If the Github author already created a database on server and provided you with credentials, then all you have to do is to update this localDB server by the server name he provided in Github page. 如果Github作者已经在服务器上创建了一个数据库并为您提供了凭据,那么您要做的就是通过他在Github页面中提供的服务器名称来更新此localDB服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM