数据库连接和应用程序与数据库的设置

时间:2011-12-30 12:02:26

标签: database connectivity

用于连接SQL SERVER Express数据库的连接字符串以及如何使用我的应用程序设置该数据库.....

1 个答案:

答案 0 :(得分:0)

以下代码段可以帮助您入门。

SQLConnectionStringBuilder bldr = new SQLConnectionStringBuilder        
    bldr.DataSource = "Server"  //Put your server or server\instance name here.  Likely YourComputerName\SQLExpress        
    bldr.InitialCatalog = "MyDB"  //The database on the server that you want to connect to.        
    bldr.UserID = "SomeUser" //The user id        
    bldr.Password = "SomePassword"  //The pwd for said user account
SQLConnection myConnection = new SQLConnection(bldr.ConnectionString)