本文介绍了SQL Express连接字符串地狱ASP.Net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SQL Express 2005正在本地运行。我有一个项目由另一个人在同一台机器上运行。所有我想做的是连接到它,不能那么难吧?



这是我在我的旧经典ASP代码中打其他数据库运行在同一实例上:



Provider = SQLOLEDB; Data Source = MYLAPTOP\MSSMLBIZ; Persist Security Info = True; User ID = TestUser; Password = letmein; Initial Catalog = TestDB



但是尝试一个版本,使.net代码抛出一个wobbler,因为他使用SQLServer驱动程序写它,所以它不喜欢Provider的东西。



这是他的代码中的原始连接字符串:



Server =(local);初始目录= TheDatabase; User Id = TheUser ; Password = ThePassword;



我去过并尝试了几个选项,这些都得到SQL Server不存在或访问被拒绝(什么可爱的混合错误

  • 数据源= localhost \SQLEXPRESS;集成安全性= True;初始目录=数据库

  • 数据源= MyLaptop\SQLEXPRESS;集成安全性= True;初始目录= li>
  • Server = MyLaptop\SQLEXPRESS;初始目录= TheDatabase;用户ID =用户;密码=密码;



  • 我在SQL Express中为MyLaptop / IUSR_MyLaptop,MyLaptop / ASPNET,MyLaptop / IWAM_MyLaptop创建了登录名,并给予他们对我的DB的所有读/写权限,并将其默认数据库设置为TheDatabase。



    我做错了什么,如何调试问题?



    更新:特别感谢Chris的所有指针,到最后,如果你有类似的问题,请阅读所有的评论有很多的链接和提示,如何跟踪他们。

    解决方案

    在您的评论中出现该错误消息,您应该通过



    我假设实例正在运行,并允许通过tcpip连接? p>

    SQL Express 2005 is running locally. I have a project written by another person running on the same machine. All I want to do is connect to it, can't be that hard right?

    This is the one I use in my old classic ASP code to hit another database running on the same instance:

    Provider=SQLOLEDB;Data Source=MYLAPTOP\MSSMLBIZ;Persist Security Info=True;User ID=TestUser;Password=letmein;Initial Catalog=TestDB

    But trying a version of that makes the .net code throw a wobbler as he's written it using SQLServer drivers so its not liking the Provider stuff.

    Here is the orginal connection string from his code:

    Server=(local);Initial Catalog=TheDatabase;User Id=TheUser;Password=ThePassword;

    I've been to http://www.connectionstrings.com/sql-server-2005 and tried several of the options from there, these all get "SQL Server does not exist or access denied" (what a lovely mixed error message that is!):

    • Data Source=localhost;Integrated Security=True;Initial Catalog=TheDatabase
    • Data Source=localhost\SQLEXPRESS;Integrated Security=True;Initial Catalog=TheDatabase
    • Data Source=MyLaptop\SQLEXPRESS;Integrated Security=True;Initial Catalog=TheDatabase
    • Server=MyLaptop\SQLEXPRESS;Initial Catalog=TheDatabase;User Id=TheUser;Password=ThePassword;

    I've created logins for MyLaptop/IUSR_MyLaptop, MyLaptop/ASPNET, MyLaptop/IWAM_MyLaptop in SQL Express and given them all read/write permissions to my DB and set their default DB to be TheDatabase.

    What the heck am I doing wrong and how can I debug the problem some more?

    UPDATE: Special Thanks to Chris for all his pointers, got there in the end, if you are having similar problem please read all the comments there are lots of links and tips on how to track them down.

    解决方案

    With that error message in your comment you should run through the items in http://blogs.msdn.com/sql_protocols/archive/2007/05/13/sql-network-interfaces-error-26-error-locating-server-instance-specified.aspx

    I presume the instance is running and does allow connections over tcpip?

    这篇关于SQL Express连接字符串地狱ASP.Net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    10-19 11:38