Chào mừng đến với Diễn đàn lập trình - Cộng đồng lập trình.
Kết quả 1 đến 4 của 4
  1. #1
    Ngày tham gia
    Sep 2015
    Bài viết
    0

    Lỗi kết nối trong asp.net

    Các bạn cho mình hỏi đây là lỗi j vậy và ai chỉ hộ mình cách sửa đc ko :

    Mã:
    Keyword not supported: 'sever'.
    
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
    
    Exception Details: System.ArgumentException: Keyword not supported: 'sever'.
    
    Source Error: 
    
    
    Line 18:     {
    Line 19:         string ketnoi = "Sever=Data Source=.\\HoangIT;Initial Catalog=QuanLy;User ID=sa;Password=***********";
    Line 20:         SqlConnection conn = new SqlConnection(ketnoi);
    Line 21:         try
    Line 22:         {
    
    Source File: c:\Users\HoangKute\Documents\Visual Studio 2010\WebSites\WebSite1\Default.aspx.cs    Line: 20 
    
    Stack Trace: 
    
    
    [ArgumentException: Keyword not supported: 'sever'.]
       System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey) +5055124
       System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules) +98
       System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) +64
       System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) +24
       System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(String connectionString, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) +150
       System.Data.SqlClient.SqlConnection.ConnectionString_Set(String value) +59
       System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) +4
       System.Data.SqlClient.SqlConnection..ctor(String connectionString) +26
       _Default.Page_Load(Object sender, EventArgs e) in c:\Users\HoangKute\Documents\Visual Studio 2010\WebSites\WebSite1\Default.aspx.cs:20
       System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
       System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
       System.Web.UI.Control.OnLoad(EventArgs e) +91
       System.Web.UI.Control.LoadRecursive() +74
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207
    Còn đây là đoạn mã mình viết :
    Mã:
     protected void Page_Load(object sender, EventArgs e)
        {
            string ketnoi = "Sever=Data Source=.\\HoangIT;Initial Catalog=QuanLy;User ID=sa;Password=***********";
            SqlConnection conn = new SqlConnection(ketnoi);
            try
            {
                conn.Open();
                Label1.Text = "ket noi ko thanh cong";
            }
            catch 
            {
    
                Label1.Text = "Ket noi  thanh cong";
            }
    Mong các pro giúp hộ mình

  2. #2
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Trích dẫn Gửi bởi gnirt69
    Lổi của bạn nằm ở chuổi kết nối, chỉ có thể Server=... hoặc là Data Source=... chứ làm gì có Server=Data Source=....
    Mã:
    Data Source =myServerAddress; Initial Catalog =myDataBase; User Id =myUsername; Password =myPassword;
    Tham khảo thêm tại : http://connectionstrings.com/sql-server-2005
    ồ đúng rồi mình thừa chỗ sever .cảm ơn 2 bạn nhiều nha [IMG]images/smilies/wink.png[/IMG]

  3. #3
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Lổi của bạn nằm ở chuổi kết nối, chỉ có thể Server=... hoặc là Data Source=... chứ làm gì có Server=Data Source=....
    Mã:
    Data Source =myServerAddress; Initial Catalog =myDataBase; User Id =myUsername; Password =myPassword;
    Tham khảo thêm tại : http://connectionstrings.com/sql-server-2005

  4. #4
    Ngày tham gia
    Sep 2015
    Đang ở
    Hà Nội
    Bài viết
    0
    [IMG]images/smilies/17.gif[/IMG] Bạn kia nói đúng rồi đó. Mình bổ sung thêm chút nữa, là bạn viết sai từ khóa server( thiếu chữ r). Thường thì bạn cứ chịu khó dịch lỗi là ra thui. Như của bạn thì dịch dòng này là thấy rồi:
    Exception Details: System.ArgumentException: Keyword not supported: 'sever'.
    sửa đúng từ khóa sẽ thấy lỗi khácgán 2 cái:server=data source=..) =>sửa nữa là hết.hi

 

 

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •