简体   繁体   English

SqlConnection,我使用的是SQL Server,而不是LocalDB; 那么如何

[英]SqlConnection, I'm using SQL Server, not LocalDB; so how to

So, in the tutorial I was checking, he uses a Database and connect it using this 因此,在我正在检查的教程中,他使用了数据库,并使用此数据库进行连接

    SqlConnection conn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\RANBAH~1\Documents\testlogin.mdf;Integrated Security=True;Connect Timeout=30");

Although, I use SQL Server Management 17, which mean I have a server, So how do i get my SQL Connect Data Source? 尽管我使用SQL Server Management 17,这意味着我有一台服务器,那么如何获得SQL Connect数据源呢? because afterward he uses it for 因为后来他用它来

SqlDataAdapter sda = new SqlDataAdapter("select count(*) from login where username ='" + textBox1.Text + "' and password='" + textBox2.Text + "'", conn);

Any clue ? 有什么线索吗?

Inside your project, in VS, connect to the server. 在项目内部,在VS中,连接到服务器。 Once you are on the server explorer, right click on the database to get the connection string. 进入服务器资源管理器后,右键单击数据库以获取连接字符串。 When you check the properties for the database, you should be able to see it. 当您检查数据库的属性时,您应该能够看到它。 You cannot get the connection string from SSMS, though you can get all the information for the connection string. 尽管可以获取有关连接字符串的所有信息,但是您无法从SSMS获取连接字符串。 Then, you can use those information to create your own connection string using this website: https://www.connectionstrings.com/ Just check which is better suited for you. 然后,您可以通过以下网站使用这些信息来创建自己的连接字符串: https : //www.connectionstrings.com/只需检查哪个更适合您。

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

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