Friday, October 16, 2009

SQL Server 2005 không cho phép remote connection cho nên chúng ta cần phải active service này lên một cách thủ công. Message sau sẽ xuất hiện trong trường hợp service này chưa được start.

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connection. ….?"

SQL Server does not allow remote connection

Login failed for user ‘sa’. The user is not associated with a trusted SQL Server connection.�?

Login failed for 'sa'

Kiểm tra quyền truy cập vào hệ thống SQL Server với account trong hệ thống của SQL Server hoặc quyền của Windows Authentication.
Ví dụ: tài khoản ‘sa’.

    1. Login vào SQL Server sử dụng công cụ SQL Server Management Studio Express trên hệ thống SQL Server với tài khoản của Windows Authentication.
      Login using Windows authentication mode on local
    2. Trong phần cửa sổ Object Explorer, click chuột phải trên tên server đã connect và chọn Properties.
      Open SQL Server Properties
    3. Trên phần của sổ trái của cửa sổ Server Properties, chọn Security và thay đổi dạng truy cập Server authentication trở thành SQL Server and Windows Authentication mode.
      Change SQL Server authentication mode
    4. Của sổ thông báo kết quả thay đổi đã thành công và yêu cầu restart lại SQL Server để làm cho những thay đổi trên có hiệu lực.
      SQL Server need restart
    5. Click chuột phải trên tên server, chọn Restart để restart lại dịch vụ SQL Server.
      Restart SQL Server Service
    6. Chọn Yes.
      Confirmation
    7. Của sổ restart dịch vụ SQL Server.
      Restarting SQL Server Service
    8. Tất cả đã hoàn tất, dịch vụ SQL Server với quyền truy cập là tài khoản của SQL Server và Windows authentication đều đã được kích hoạt.
  • Kiểm tra dịch vụ remote connection vào server SQL trên công cụ SQL Server Surface Area Configuration
    1. Mở chương trình SQL Server Surface Area Configuration.
      Open SQL Server Surface Area Configuration
    2. Click vào chức năng Surface Area Configuration for Services and Connections (chọn lựa đầu tiên trong 2 chức năng).
      Open Surface Area Configuration for Services and ConnectionsTrên phần cửa sổ bên trái của cửa sổ vừa mở ra, chọn SQL Server instance -> Database Engine -> Remote Connections. Trên phần bên phải, chọn Local and remote connections -> using both TCP/IP and named pipes.
      Allow remote connections
    3. Tiếp theo trên phần trái của cửa sổ, chọn SQL Server Browser -> Service.
      Trên phần phải của cửa sổ, Hãy start dịch vụ và để nó ở chế độ Automatic. Sau đó nhấn OK.
      Start SQL Server Browser
    4. Sau khi tiến hành các bước cấu hình trên, hệ thống đã có thể tiến hành remote connect từ một máy khác trong hệ thống mạng.
      Login to remote SQL Server
    5. Trang login.
      Login succeeded

Monday, August 4, 2008

SQL Server 2005 Express Edition

Keywords: SQL Server 2005 Express, SQLExpress, SQLServer2005, SQL2005,

1. Cài đặt .NET Framework 2.0
2. Cài đặt Microsoft SQL Server 2005 Express Edition
3. Cài đặt SQL Server Management Studio Express

SQL Server 2005 Express Edition (SSE) là phiên bản desktop của sản phẩm cơ sở dữ liệu SQL Server 2005 rất phổ biến của Microsoft. Phiên bản SQL Server 2005 Express Edition được cung cấp miễn phí cho người sử dụng.

1. Cài đặt .NET Framework 2.0

SSE đi với bộ công cụ phát triển phần mềm Visual Studio.NET 2005 nên yêu cầu cần phải có .NET Framework 2.0. Link download .NET Framework 2.0: http://msdn2.microsoft.com/netframework/

2. Cài đặt Microsoft SQL Server 2005 Express Edition

SQL Server 2005 Express Edition là phiên bản desktop làm server dữ liệu SQL trên máy PC x86. SSE có đặc điểm là miễn phí, dễ sử dụng, kích thước file cài đặt nhỏ gọi chỉ với 36.5MB.

Link download : http://go.microsoft.com/fwlink/?LinkId=65212

3. Cài đặt SQL Server Management Studio Express

SQL Server Management Studio Express để dễ quản lý database, nó giúp bạn tạo database dễ dàng hơn. Trường hợp không cần công cụ quản lý dữ liệu thì không cần cài đặt phần này.

Link download: http://go.microsoft.com/fwlink/?LinkId=65110

Trước khi cài cần phải có MSXML 6.0.

(Link download : http://www.microsoft.com/downloads/details.aspx?familyid=993c0bcf-3bcf-4009-b...)



4. Câu lệnh kết nối đến SQL Express

SQLServer2000:

m_szConnectString.Format("Provider=SQLOLEDB;Data Source=%s; Trusted_Connection= yes; User Id = %s; Password=%s; Initial Catalog=%s", m_szServer, m_szUsername, m_szPassword, m_szDatabase);

SQLExpress2005:

m_szConnectString.Format("Provider=SQLNCLI; Server=HUNGNQ\\SQLEXPRESS; Trusted_Connection=yes; Database=%s; User Id=%s; Password=%s; Initial Catalog=%s", m_szUsername, m_szPassword, m_szDatabase);

m_szConnectString.Format("Provider=SQLNCLI; Server=HUNGNQ\\SQLEXPRESS; Persist Security Info=True; User Id=%s; Password=%s; Initial Catalog=%s;", m_szServer, m_szUsername, m_szPassword, m_szDatabase);