[英]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;
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.