1/2页12 跳转到查看:748
发新话题 回复该主题

求助数据库连接问题!

求助数据库连接问题!


 附件: 您所在的用户组无法下载或查看附件

TOP

 

你是不是用windows默认的登录方式?

TOP

 

把constring贴出来看看?

TOP

 

回复 2# fengyangchao 的帖子

不是,我用的是混合式

TOP

 

回复 2# fengyangchao 的帖子

不是,我用的是混合式

TOP

 

回复 1# xxsq741852 的帖子

不是,我用的是混合式

TOP

 

回复 1# xxsq741852 的帖子

1)确认连接SQL Server使用的命名空间不是"System.Data.OleDb",还是"System.Data.SqlClient"
2)确认连接字符串,给你介绍一下参数:
  "user id=sa":连接数据库的验证用户名为sa.他还有一个别名"uid",所以这句我们还可以写成"uid=sa".
  "password=":连接数据库的验证密码为空.他的别名为"pwd",所以我们可以写为"pwd=".
  这里注意,你的SQL Server必须已经设置了需要用户名和密码来登录,否则不能用这样的方式来登录.如果你的SQL Server设置为Windows登录,那么在这里就不需要使用"user id"和"password"这样的方式来登录,而需要使用"Trusted_Connection=SSPI"来进行登录.
  "initial catalog=Northwind":使用的数据源为"Northwind"这个数据库.他的别名为"Database",本句可以写成"Database=Northwind".
  "Server=YourSQLServer":使用名为"YourSQLServer"的服务器.他的别名为"Data Source","Address","Addr".如果使用的是本地数据库且定义了实例名,则可以写为"Server=(local)\实例名";如果是远程服务器,则将"(local)"替换为远程服务器的名称或IP地址.
  "Connect Timeout=30":连接超时时间为30秒.
3)建立连接对象用的构造函数为:SqlConnection
你自己检查一下吧!

TOP

 

回复 2# fengyangchao 的帖子

<connectionStrings>
  <add name="film" connectionString="server=(local);database=MoiveFilm; uid=sa;pwd=sa " />
</connectionStrings>

TOP

 

回复 8# xxsq741852 的帖子

用户代码未处理 System.Data.SqlClient.SqlException
  Message="无法打开登录 'MoiveFilm' 中请求的数据库。登录失败。\r\n用户 'sa' 登录失败。"
  Source=".Net SqlClient Data Provider"
  ErrorCode=-2146232060
  Class=11
  LineNumber=0
  Number=4060
  Procedure=""
  Server="(local)"
  State=1
  StackTrace:
      在 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
      在 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
      在 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, Int64 timerExpire, SqlConnection owningObject)
      在 System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
      在 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, 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.select_notice() 位置 d:\studynet\ASP.NET 2.0全程指南(程序)\MovieFilm\App_Code\system.cs:行号 29
      在 head.Page_Load(Object sender, EventArgs e) 位置 d:\studynet\ASP.NET 2.0全程指南(程序)\MovieFilm\head.master.cs:行号 17
      在 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.Control.LoadRecursive()
      在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  InnerException:

TOP

 

<connectionStrings>
  <add name="film" connectionString="server=(local);database=MoiveFilm; Integrate Security=SSPI " />
</connectionStrings>

TOP

 
1/2页12 跳转到
发表新主题 回复该主题