* TDS Generic Provider
Server=hostname;Database=databaseName;User ID=userid;Password=password
using System; using System.Data; using Mono.Data.TdsClient; public class Test { public static void Main(string[] args) { string connectionString = "Server=localhost;" + "Database=pubs;" + "User ID=myuserid;" + "Password=mypassword;"; IDbConnection dbcon; dbcon = new TdsConnection(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; } }
mcs TestExample.cs -r System.Data.dll \ -r Mono.Data.TdsClient.dll
mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \ TestExample.cs \ -lib:C:/cygwin/home/MyHome/mono/install/lib \ -r System.Data.dll -r Mono.Data.TdsClient.dll
mono TestExample.exe