X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=web%2Fsqlclient;h=eca4906cbe342376673bdcb558ec834b133e1928;hb=0c2899f27cef2bd78c6ac79b3a4363d8bab9e791;hp=d17f4695593ad19ad80360d82099f92750c071a5;hpb=3570fe498f7ebabafe6baf6e26e2a035d1df0d54;p=mono.git diff --git a/web/sqlclient b/web/sqlclient index d17f4695593..eca4906cbe3 100755 --- a/web/sqlclient +++ b/web/sqlclient @@ -31,11 +31,12 @@ ** Action plan @@ -89,16 +87,17 @@ -
  • If using Microsoft SQL Server 2000, make sure +
  • IMPORTANT: If using Microsoft SQL Server 2000, make sure you are using at least Service Pack 3 for Microsoft SQL Server 2000. If using - MSDE 2000, make sure you have the special Service Pack 3 for MSDE 2000.
  • + MSDE 2000, make sure you have the special Service Pack 3 for MSDE 2000. You + can get it from here
  • For those that only have MSDE installed. You can change the authentication mode from Windows Only Authentication to SQL Server and Windows Authentications (also knows as Mixed-mode authentication) via the registry
  • . It is the LoginMode you need to change. By default, - MSDE is installed with Windows Only Authentication. For SqlClient to work with MSDE, you will - need to change the setting. + MSDE is installed with Windows Only Authentication. If you want SqlClient to work with MSDE via SQL Server authentication, you will + need to change the setting. Otherwise, you wil have to use NT Authentication.
  • If using MSDE, you might need to create a new user with password. Give this user access to various databases in this MSDE instance. Also, for each @@ -109,23 +108,35 @@ for both MSDE and Microsoft SQL Server. To change the authentication mode in Enterprise Mananger, select the instance, right-click on it, and select properites. The SQL Server properties dialog for that instance will pop up. Choose the Security - tab. Change the authentication from Windows Only to SQL Server and Windows. If + tab. Change the Authentication from Windows Only to SQL Server and Windows. If the instance of your database does not show up in Enterprise Manager, Register first by selecting the Action menu and choosing New SQL Server Registration.
  • Located at mcs/class/System.Data/Test is a test for System.Data.SqlClient named SqlTest.cs and you could use this as a basis for your test.
  • -
  • Mono's SqlClient does not support trusted connections - nor integrated security. You can not use this when connecting. You need - to explicitly use a User ID and Password - authenticated by SQL Server.
  • +
  • If you want to use Integrated Security (aka NT Authentication aka Trusted Connection aka Domain Login), you + will need to specify the Domain User ID and Password. This is because Mono is not integrated with Windows + nor SQL Server.
  • -
  • Has a connection string format: +
  • Has a connection string format for SQL Server Authentication:
    - Server=hostname;Database=databaseName;User ID=userid;Password=password
    + Server=hostname;
    + Database=databaseName;
    + User ID=sqlServerUserid;
    + Password=sqlServerPassword
     
  • +
  • Has a connection string format for NT Authentication: +
    + Server=hostname;
    + Database=databaseName;
    + User ID=windowsDomain\windowsUserid;
    + Password=windowsPassword;
    + Integrated Security=SSPI
    +
    +
  • +
  • The Server part can be used three ways: @@ -142,12 +153,12 @@ - +
    hostname\\instance Server=MYHOST\\NETSDKhostname\instance Server=MYHOST\NETSDK
  • -
  • C# Example: +
  • C# Example using SQL Server Authentication:
      using System;
      using System.Data;
    @@ -158,10 +169,10 @@
         public static void Main(string[] args)
         {
            string connectionString = 
    -          "Server=localhost;" +
    +          "Server=MyServer;" +
               "Database=pubs;" +
    -          "User ID=myuserid;" +
    -          "Password=mypassword;";
    +          "User ID=MySqlServerUserId;" +
    +          "Password=MySqlServerPassword;";
            IDbConnection dbcon;
            dbcon = new SqlConnection(connectionString);
            dbcon.Open();
    @@ -188,18 +199,56 @@
      }
     
  • + +
  • C# Example using NT Authentication (Integrated Security) +
    + using System;
    + using System.Data;
    + using System.Data.SqlClient;
    + 
    + public class Test 
    + {
    +    public static void Main(string[] args)
    +    {
    +       string connectionString = 
    +          "Server=MyServer;" +
    +          "Database=pubs;" +
    +          "User ID=MyWindowsDomain\\MyWindowsUserid;" +
    +          "Password=MyWindowsPassword;" +
    +          "Integrated Security=SSPI";
    +       IDbConnection dbcon;
    +       dbcon = new SqlConnection(connectionString);
    +       dbcon.Open();
    +       IDbCommand dbcmd = dbcon.CreateCommand();
    +       string sql = 
    +           "SELECT fname, lname " +
    +           "FROM employee";
    +       dbcmd.CommandText = sql;
    +       IDataReader reader = dbcmd.ExecuteReader();
    +       while(reader.Read()) {
    +            string FirstName = (string) reader["fname"];
    +            string LastName = (string) reader["lname"];
    +            Console.WriteLine("Name: " + 
    +                 FirstName + " " + LastName);
    +       }
    +       // clean up
    +       reader.Close();
    +       reader = null;
    +       dbcmd.Dispose();
    +       dbcmd = null;
    +       dbcon.Close();
    +       dbcon = null;
    +    }
    + }
    +
    +
  • +
  • Building C# Example: