初学asp.net 有个问题很麻烦:
  说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.OleDb.OleDbException: 无效的授权说明
无效的连接字符串属性源错误: 
行 34:         OleDbConnection con = new OleDbConnection(strcon);
行 35:         OleDbCommand cmd = new OleDbCommand();
行 36:             con.Open();--------------------------------出错行代码
行 37:             cmd.Connection = con;
行 38:             cmd.CommandText = sql;
  protected void submit_Click(object sender, EventArgs e)
    {        string namea = name.Text;
        string sexa = sex.Text;
        string proa = pro.Text;
        string bza =bz.Text;
        string strcon = @"Provider = SQLNCLI ; Server = (DDKILLER)\SQLEXPRESS ; Database = HD ; Trusted_Connection = yes ;";
        string sql = "insert into users(name,sex,pro,bz,date) values('" + namea + "','" + sexa + "','" + proa + "','" + bza + "','" + System.DateTime.Now + "')";
        OleDbConnection con = new OleDbConnection(strcon);
        OleDbCommand cmd = new OleDbCommand();
            con.Open();
            cmd.Connection = con;
            cmd.CommandText = sql;
            cmd.ExecuteNonQuery();
            Response.Write("name=" + namea + "<br>");
            Response.Write("sex=" + sexa + "<br>");
            Response.Write("pro=" + proa + "<br>");
            Response.Write("bz=" + bza + "<br>");
            Response.Write("date=" + System.DateTime.Now);
            Response.Write(sql);
    }
}无论如何也解决不了,望高手赐教

解决方案 »

  1.   

    不知道这样的链接字符串对不对 如果是自己写的可能会出错
    http://www.connectionstrings.com
      

  2.   

    我就是按照您连接里边的SQL2005里边链接实例copy过来的,但是还是不对
      

  3.   

    你的是 oledbconnection的方式
    你是否用了sqlconnection的方式
      

  4.   

    Attach a database file on connect to a local SQL Server Express instance:"Provider=SQLNCLI;Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf;Database=dbname;Trusted_Connection=Yes;" 
       - or -
    "Provider=SQLNCLI;Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf;Database=dbname;Trusted_Connection=Yes;" 
       (use |DataDirectory| when your database file resides in the data directory)引用:http://www.cnblogs.com/murky/archive/2006/07/06/443822.html看看你的分号是不是全角的。
      

  5.   

    连接mssql,用System.Data.SqlClient空间下面的sqlconnectionusing System.Data.SqlClient;
    public class sqlServerConnection {
    //
    public static void Main() {//下面就是标准的连接,注意SERVER是我的计算机名。SQLEXPRESS是数据库实例。SSPI表示使用Windows登陆的帐户。master是要连接的数据库。
    //                                      //初始目录//         //综合的,完整的:集成(信息)//
    string cstr = "server=SERVER\\SQLEXPRESS;Initial Catalog=master;Integrated Security=SSPI";
    //
    try {
    //
    using (SqlConnection con = new SqlConnection(cstr)) {
    con.Open();
    System.Console.WriteLine("ServerVersion:{0}",con.ServerVersion);
    System.Console.WriteLine("State:{0}",con.State);
    }
    //
    }
    catch (System.Exception sqle) {
    System.Console.WriteLine(sqle.Message);
    }
    //}
    //
    }
      

  6.   

    你应该用sql而不是oledb的吧。