C # Development Environment Establishment Steps (WindowxP SP2, SQLServer2000) 1, Microsoft® .NET Framework 1.1 version can be transferred to the set http://www.microsoft.com/downloads/details.aspx?displaylang=zh-tw&familyId=262d25e3-f589- 4842-8157-034D1E7CF3A3DOTNETFX.EXE (Traditional)
2, download Microsoft® .NET Framework SDK 1.1 http://www.microsoft.com/downloads/details.aspx?displaylang=zh-tw&familyId=9b3a2ca6-3647-4070-9f41-a333c6b9181dsetup.exe
3, download IDE (free, multi-language) http://prdownloads.sourceForge.Net/sharpDevelop/sharpdevelop_1.0.3.1768_setup.exe?Use_mirror=jaistsharpDevelop_1.0.3.1768_setup.exe
4, the Options submenu under the Tools menu, select our national flag, this way of helping all is Chinese. 5, file new project C #, console application. Example: / * * Created by SharpDevelop. * User: from book * Date: 2005/2/24 * * To change this Template Use Tools | Options | Coding | Edit Standard Headers . * / Using system.data.sqlclient;
namespace MyConsoleApplication {class MainClass {public static void Main (string [] args) {try {// step1: create a connection obj SqlConnection mySqlConnection = new SqlConnection ( "server = 192.168.1.61; database = Northwind; uid = sa; pwd = sa "); // step2: create a sqlcommand obj SqlCommand mySqlCommand = mySqlConnection.CreateCommand (); // step3: set the sql mySqlCommand.CommandText =" SELECT CustomerID, CompanyName, ContactName, Address " " FROM Customers " " WHERE CustomerID = 'ALFKI' "; // step4: open connection mySqlConnection.Open (); // step5: create a SqlDatareader object SqlDataReader mySqlDataReader = mySqlCommand.ExecuteReader (); // step6: read th row from sqldatareader mySqlDataReader.Read () ; // step7: display the colum values Console.WriteLine ( "mySqlDataReader [/" CustomerID / "] =" mySqlDataReader [ "CustomerID"]); Console.WriteLine ( "mySqlDataReader [/" CompanyName / "] =" mySqlDataReader ["CompanyName"]); console.writeline ("MySQ lDataReader [/ "ContactName /"] = " mySqlDataReader [" ContactName "]); Console.WriteLine (" mySqlDataReader [/ "Address /"] = " mySqlDataReader [" AddresS "]); // step8: close sqldataReader object mySqlDataReader.Close (); // step9: close the SqlConnection Object mySqlConnection.Close ();} catch (SqlException e) {Console.WriteLine ( "A SqlException was thrown"); Console.WriteLine ( "Number =" e. Number); console.writeline ("message =" E.MESSAGE); console.writeline ("