* Microsoft SQL Server Provider
- ADO.NET Provider for Microsoft SQL Server 7/2000 databases
- Exists in namespace System.Data.SqlClient and assembly System.Data
- Created by Tim Coleman
- Used the FreeTDS and
jTDS projects as resources.
- Implemented in 100% C#
- Is similar to the Mono.Data.TdsClient and Mono.Data.SybaseClient providers.
- Requires the assembly Mono.Data.Tds.dll which implements the TDS protocol in 100% C#.
- Uses TDS Protocol Version 7.0
- Does not support trusted connections
** Current Status
- Able to connect to Microsoft SQL Server 7/2000 databases
- Connection pooling works.
- Stored Procedures work
- Parameters work.
- Prepare works.
- SQL commands can be executed
via ExecuteNonQuery() of a SqlCommand.
- SQL aggregates can be executed and a single row and single column
result can be retrieved via ExecuteScalar() of a SqlCommand
- SQL queries can be executed via ExecuteReader() and results
can be retrieved via SqlDataReader.
- a DataTable with schema info about a result can be gotten via GetSchemaTable()
in a SqlDataReader
- XML can be read via ExecuteXmlReader in a SqlCommand.
- Data can be filled in a DataTable in a DataSet via a SqlDataAdapter
- Uses TDS Protocol Version 7.0
- Design of the Microsoft SQL Server, Sybase, and TDS Providers in Mono
** Action plan
- Connection timeouts is being developed now.
- Needs more testing...
** Testing
- Have a working mono and mcs installed
- Have access to a Microsoft SQL Server database
or either download it:
- 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.
- C# Example:
using System;
using System.Data;
using System.Data.SqlClient;
public class Test
{
public static void Main(string[] args)
{
string connectionString =
"Server=localhost;" +
"Database=pubs;" +
"User ID=sa;" +
"Password=;";
IDbConnection dbcon;
dbcon = new SqlConnection(connectionString);
IDbCommand dbcmd = dbcon.CreateCommand();
string sql =
"SELECT fname, lname " +
"FROM employee";
dbcmd.ConnectionString = sql;
IDataReader reader = dbcmd.ExecuteReader();
while(reader.Read()) {
string FirstName = reader["fname"];
string LastName = reader["lname"];
Console.WriteLine("Name: " +
FirstName + " " + LastName);
}
// clean up
reader.Close();
reader = null;
dbcmd.Dispose();
dbcmd = null;
dbcon.Close();
dbcon = null;
}
}
- Building C# Example:
- Running the Example:
mono TestExample.exe