我的是个人开发SQL SERVER版+SP4的,VS。NET 2003
server={SQL server};server=BANTENE;uid=sa;pwd=gdyutao;database=xuncn
我连接的字符是上面的,不管我换成怎么样,都出现以下的错误。--------------------------------------------------------------------------------用户 'sa' 登录失败。原因: 未与信任 SQL Server 连接相关联。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.SqlClient.SqlException: 用户 'sa' 登录失败。原因: 未与信任 SQL Server 连接相关联。请问这是什么原因啊

解决方案 »

  1.   

    我的是集成WINDOWS身份验证,不是SQL验证
      

  2.   

    把 "server={SQL server};"去掉
      

  3.   

    试试下面
    "Data Source=ip;Initial Catalog=BANTENE;User Id=sa;Password=xuncn;" 参考
    http://www.connectionstrings.com/要确保sa密码正确
      

  4.   

    要混合模式才行。
    重新安装SQLSERVER,安装的时候选择混合模式才能在程序里连上数据库。
      

  5.   

    不会吧,,但是我的IIS也是集成WINDOWS验证模式啊
      

  6.   

    sql是否启用了混合认证模式,请查一下,默认是只启用windows认证的,哪怕输入了sa的密码右键属性看security
      

  7.   

    SqlConnection conn = new SqlConnection("server=boss;database=vote;uid=sa;pwd=;");
      

  8.   

    booro(特鸟飞勤) ( ) 信誉:34  2006-03-24 21:48:00  得分: 0  
     
     
       不会吧,,但是我的IIS也是集成WINDOWS验证模式啊
      -----------------------------------------------------
      我的程序集成WINDOWS模式,死活也连不上,问了下高手,告诉我重新安装SQL,选混合模式,问题马上解决了。
      

  9.   

    不会吧,我现在装了混合模式也不行,你们的SQL数据库是什么版本的
      

  10.   

    信誉好低啊 呵呵你先用这个测试一下看能不能 这个是能运行的 我也是刚学 还有你的服务管理器启动没有啊
    sql.aspx
    <%@ Page language="c#" Codebehind="sql.aspx.cs" AutoEventWireup="false" Inherits="Web.sql" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>sql</title>
    <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
    <meta name="CODE_LANGUAGE" Content="C#">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    </HEAD>
    <body MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
    <asp:Label id="data_src" runat="server" /><br>
    <asp:Label id="con_open" runat="server" /><br>
    <asp:Label id="con_close" runat="server" />
    </form>
    </body>
    </HTML>sql.aspx.cs
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data.SqlClient;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;namespace Web
    {
    /// <summary>
    /// sql 的摘要说明。
    /// </summary>
    public class sql : System.Web.UI.Page
    {
    protected System.Web.UI.WebControls.Label data_src;
    protected System.Web.UI.WebControls.Label con_open;
    protected System.Web.UI.WebControls.Label con_close;

    private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面
    string strConnection = "user id = sa ; password  = sa;";
    strConnection+="initial catalog = northwind; server = MS-CE9A8FE8DA28;";
    strConnection+="Connect Timeout = 30";
    data_src.Text = strConnection;
    SqlConnection objConnection = new SqlConnection(strConnection);
    try
    {
    objConnection.Open();
    con_open.Text = "Connection opend successfully";
    objConnection.Close();
    con_close.Text = "Connection closed";
    }
    catch (Exception ee)
    {
    con_open.Text = "Connection failed to open";
    con_close.Text = ee.ToString();
    }
    } #region Web 窗体设计器生成的代码
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {    
    this.Load += new System.EventHandler(this.Page_Load); }
    #endregion
    }
    }
      

  11.   

    用查询分析器能连接否?如果可以,再试试在vs.net的服务器资源管理器中新建个数据连接试试,如果还是可以的话,就用他生成的连接字符串
      

  12.   

    我也有过,是因为权限的问题,
      你每次建数据库是都要对可库添加权限,这样就可以了,就好是asp.net身份的那种身份```