简体   繁体   English

sqlserver连接字符串中的用户名,密码和其他参数

[英]username , password and other parameters in sqlserver connection string

I'm new to C# and .net and just worked with php and mysql. 我是C#和.net的新手,只是使用php和mysql。
to connect to sqlserver express (in visual studio 2010) with c# we should provide a connection string that has lots of formats i found on the web specially in connectionstrings . 要使用c#连接到sqlserver express(在visual studio 2010中),我们应该提供一个连接字符串,它具有我在网络上特别在连接字符串中找到的许多格式。
for example in standard format : 例如,标准格式:
"Data Source=myServerAddress;Initial Catalog=myDataBase;UserId=myUsername;Password=myPassword;" “Data Source = myServerAddress; Initial Catalog = myDataBase; UserId = myUsername; Password = myPassword;”

what is username and password? 什么是用户名和密码? where can i find them? 我在哪里可以找到它们? are they "root" and "" like in php mysql or something else? 他们是“root”和“”喜欢在php mysql或其他东西?

as mentioned , i have created a database named "db.sdf" in sqlserver express in visual studio 2012. 如上所述,我在visual studio 2012中的sqlserver express中创建了一个名为“db.sdf”的数据库。

I'm really confused. 我真的很困惑。 please help. 请帮忙。

If your database extension is SDF ,you are creating SQL Server CE ( Compact Edition ) database file. 如果您的数据库扩展名是SDF ,则表示您正在创建SQL Server CE精简版 )数据库文件。 Use this connection string 使用此连接字符串

Data Source=" + (System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\MyData.sdf;Persist Security Info=False;

OR 要么

Data Source=MyData.sdf;Persist Security Info=False;

More on this link. 更多关于此链接。

UPDATE 1 更新1

You need the System.Data.SqlServerCe namespace. 您需要System.Data.SqlServerCe命名空间。

SqlCeConnection conn = new SqlCeConnection("Data Source=\\Mobile\\Northwind.sdf;");
conn.Open();
.
.
.
conn.Close();

From MSDN : 来自MSDN
Namespace: System.Data.SqlServerCe 命名空间: System.Data.SqlServerCe
Assembly: System.Data.SqlServerCe (in system.data.sqlserverce.dll) 程序集: System.Data.SqlServerCe(在system.data.sqlserverce.dll中)

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

相关问题 以编程方式检查连接字符串的用户名/密码? - Programmatically checking a connection string username/password? 动态为连接字符串提供用户名和密码 - Dynamically Provide Username and password to Connection String 使用 AJAX 在 SqlServer 中插入用户名、密码 - Using AJAX for Inserting UserName, Password in SqlServer Sharepoint 使用用户名和密码连接 - Sharepoint connection with a username and password 如何在连接字符串中设置用户名和密码以连接数据库? - How to set username and password in connection string for connecting to database? 在 ASP.Core MVC 中使用用户名和密码设置连接字符串 - Setting connection string with username and password in ASP.Core MVC 使用用户名/密码验证与 activeMQ 的连接 - authenticate connection to activeMQ with username/password SqlServer中的连接超时属性连接字符串不起作用 - Connection Timeout property in SqlServer Connection string not Working c#.net连接字符串具有集成安全性,但在指定用户名和密码时不起作用 - c#.net connection string works with integrated security but not when specifying username and password 如何在Startup.cs之外设置数据库连接字符串用户名和密码? - How to set DB connection string username & password outside of Startup.cs?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM