用windows登录sql sever和用“sa”登录都可以;
但是用visual studio测试连接,windows验证测试成功,“sa”测试连接失败
真心求教,谢谢了
但是用visual studio测试连接,windows验证测试成功,“sa”测试连接失败
真心求教,谢谢了
解决方案 »
- C# 发布网站上传到FTP上出现这个问题要怎么解决
- .NET开发过程中总会报控件不足
- Excel如何导入数据库中的复合表
- 怎么把radiobuttin在SqlDataReader获取出来
- 这样的场景中应用那个设计模式最合适?
- 有关邮件附件问题
- .net编程向excel2003新插入一行?如何实现?搜索整个MSDN没有答案,才提问
- 高分!!向高手请教在C#中若干SQL的应用问题
- 请教这个问题 急!!! 要启用实时(JIT)调试
- 如何确保与数据库的连接不断开呢?
- 求解:怎样在 gridControl 中添加新行?
- Response.Write("<script>disDiv();</script>");后页面样式改变,样式表不起作用,求解~~!
http://yueyunzong.blog.163.com/blog/static/1944327620109985959279/http://hi.baidu.com/thankfuls/blog/item/25b99af85e74ee969f5146fe.html
builder.MaxPoolSize = 200;
builder.MinPoolSize = 50;
builder.IntegratedSecurity = true;
builder.InitialCatalog = "DemoDB";
builder.DataSource = ".\\SQLEXPRESS";
builder.Pooling = true; //创建使用Windows登陆的 SqlConnection对象
SqlConnection con = new SqlConnection("server=.;uid=sa;pwd=sa;database=demodb");
//创建SqlCommand对象
SqlCommand com = con.CreateCommand();
com.CommandText = "SELECT * FROM Employee"; //创建数据适配器对象
SqlDataAdapter adpt = new SqlDataAdapter();
adpt.SelectCommand = com; //填充DataSet
DataSet ds = new DataSet();
adpt.Fill(ds);这是代码 谢了
<add name="Default" connectionString="Data Source=.;Initial Catalog=BookShop;Persist Security Info=True;User ID=sa;Password=sa;"/>
<add name="BackUp" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=E:\新建文件夹\net\src\BookShop\BookBack.Web\App_Data\BookShop.mdf;Integrated Security=True;User Instance=True"/>
</connectionStrings>这个也不行!!
Message=无法打开登录所请求的数据库 "demodb"。登录失败。
用户 'dshl-PC\dshl' 登录失败。
Source=.Net SqlClient Data Provider
ErrorCode=-2146232060
Class=11
LineNumber=65536
Number=4060
Procedure=""
Server=.\SQLEXPRESS
State=1
StackTrace:
在 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
在 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
在 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
在 System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
在 System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject)
在 System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout)
在 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
在 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
在 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
在 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
在 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
在 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
在 System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
在 System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
在 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
在 System.Data.SqlClient.SqlConnection.Open()
在 System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
在 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
在 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
在 _Default.Page_Load(Object sender, EventArgs e) 位置 e:\新建文件夹\net\src\第15章\205\ConnectSQLServer\Default.aspx.cs:行号 42
在 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
在 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
在 System.Web.UI.Control.OnLoad(EventArgs e)
在 System.Web.UI.Control.LoadRecursive()
在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException: 无法打开登录所请求的数据库 "demodb"。登录失败。
用户 'dshl-PC\dshl' 登录失败。
SqlConnection con = new SqlConnection("server=.;uid=sa;pwd=sa;database=demodb");
这一句改为
SqlConnection con = new SqlConnection("server=.\\SQLEXPRESS;uid=sa;pwd=sa;database=demodb");试下
服务器名称:DSHL-PC\SQLEXPRESS “sa”登录失败