×

Loading...
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。

PROBLEM:ASP.NET 和SQL SERVER

WINDOWS XP,SQL2000,.NET问题:
SQL用MIX authentication,如果是standard type用户xxx,
string connectionString="server=localhost;uid=xxx;pwd=1234;database=northwind";
string commandString="select * from Customers";
SqlDataAdapter dataAdapter=new SqlDataAdapter(commandString,connectionString);
上述C#代码完全OK,但是如果是XP的用户YYY,没有password,而且进XP是用YYY登陆的,怎么写connectionString?试了大半天不行,但是可以直接用当前连接在SQL Enquiry查询,也能在form上加一个dataadapter控件测试直接用windows连接到数据库OK。

谢谢! email: henhen001@yahoo.com
Report

Replies, comments and Discussions:

  • 工作学习 / IT技术讨论 / PROBLEM:ASP.NET 和SQL SERVER
    WINDOWS XP,SQL2000,.NET问题:
    SQL用MIX authentication,如果是standard type用户xxx,
    string connectionString="server=localhost;uid=xxx;pwd=1234;database=northwind";
    string commandString="select * from Customers";
    SqlDataAdapter dataAdapter=new SqlDataAdapter(commandString,connectionString);
    上述C#代码完全OK,但是如果是XP的用户YYY,没有password,而且进XP是用YYY登陆的,怎么写connectionString?试了大半天不行,但是可以直接用当前连接在SQL Enquiry查询,也能在form上加一个dataadapter控件测试直接用windows连接到数据库OK。

    谢谢! email: henhen001@yahoo.com
    • try trust connection. Windows user can login to SQL Server automatically if it set to trust connection
      • 谢谢,总算可以中文了。
        it said lack of true connection.But I don't know how to set up,could you give me more details?Thanks.
    • then whats the error msg?
      • excuse me,I can't remember although I saw it many many times.it seems:
        login failed .....user "localhost\xxxx", not associate with any trust connection.
        when it forward next to do enquiry.
    • 没有必要使用这种连接方法。因为ASP是在用户登录之前就已经在运行了。asp.NET使用一个叫"ASPNET"的用户名,可以使用信任连接,ASP.NET访问数据库就会使用这个LOGIN, 应在数据库内配置这个用户的权限
      • 谢谢,我以为还这个用户不用设置呢。:-)
        • OK了,加了ASPNET用户,昨天用了Integrated Security 的,就是没在SQL SERVER中设。跟大家报告一下结果,以后有问题再问。 :-)
    • 这儿概念有点混淆. 1.you can't use the XP login ID to specify the conectionstring with sql server if you want to use non-trusted connection since the user info in the conectionstring is from sql authentication.
      2. To use the trusted connection, u have to add that user to the sql server security via windows authentication under the specific domain and set "tursted_connection=YES" in your connectionstring.
      • Thanks very much,我就是没找到你说的那句,再次感谢大家~~~ ^o*