???? ??????? ?? ?????? ?? ?? ADO.NET 2005 ?? ????? C# 2005 ?? ????? ?? ?? ADO.NET ?? ????? C# .NET ?? ????? ?? ???? ???? ?? ????? ?? ??? ???? ????

???? ?????? ???? ??????
???? ID: 306636 - ?? ???????? ?? ?????? ??? ?? ?? ???? ???? ???? ??.
??? ?? ??????? ???? | ??? ?? ??????? ????

?? ????? ??

??????

?? ??? ?? ??? ???? ???? ???? ???? ?? ????? ?? ??? ?? ???? ??????? ?? ?????? ???? ?? ??? ADO.NET 2005 ?? ADO.NET ?? ????? ???? ?? ??? ???? ?????? ???

??????????

????? ???? outlines ???????? ?????????, ??????????, ??????? ??????, ?? ???? ???? ???:
  • Microsoft Windows Server 2003, Microsoft Windows 2000 Professional, Windows 2000 ?????, Windows 2000 ?????, ????? ???? ?? Microsoft Windows NT 4.0 ?????
  • Microsoft Visual Studio 2005 ?? Microsoft Visual Studio .NET
?? ???? ????? ?? ?? ?? ????? ???? ?? ?????? ???:
  • ?????? ?? ???????
  • ?????? ?????? ???? (SQL)

???? ???? ?? ????? ?? ??? ???? ????

???? ?????? ?? ??? ???????? ?? ???? ?? ??? ?? ???? ??????? ?? ???? ?? ???? ??? ?? ???? ?? ??? ?? ????? ???? ?? ??? ??????? ?? ??? ???? ???? ?? ???? ?? ????? ?? ???? ???OleDbCommand??SqlCommand???? ???? ?????? ???? ?? ??? ??? ???? ??????? ???? ?? ??? ???? ??OleDbCommand?? ???? ???? ?????? ???? ?? ??? ??????? ??? ????????? ???? ?? ?? ???? ?? ?????SqlClient???? (Microsoft SQL ??? ??? ???????? ?? ?????? ???? ?? ??? ?????) ??OleDb(???? ?? ??????? ?? ??? ??? OLE DB ?? ODBC ??????? ?????? ??) ???? ??? ADO.NET. ???????, ??? ?? ????????: ????? ?? ??? ?????

ADO, ?? ??? ?? ?? ?????? ?? ???? ????? ?? ???? ???????,???????, ??Recordset???????? ??? ADO.NET, ???? ??????????????? (SqlCommand??,OleDbCommand) ???? ??????

???? ???? ?? ????? ?? ??? ????? ????? ?? ???? ????:
  1. Microsoft Visual C# 2005 ?? Visual Microsoft C# .NET ??? ??? ??? ????? ????????? ?? ????? ?? ???, ????? ????? ?? ???? ????:
    1. Microsoft Visual Studio 2005 ?? Microsoft Visual Studio .NET ??????? ????..
    2. ????? ???????????? ??,????? ????-????? ????, ?? ???? ????????????.
    3. ???????? ?????????????? ????? ???, ????? ????????? C# ??????????? ???????????????? ???????? ????-????? ????, ?? ???? ???????? ??????????? ???????????????.

      ???:Visual Studio 2005, ??? ????? ????????? C#?? ???????????????? ?????????????? ?????????????? ????? ??? ??? ????? ?? ???? ????, ?? ???? ???????? ??????????? ???????????????.
  2. ????????? ???? ?? ???? ????????? ?? ??? ??? ?????? ???System.Data??? ?????, ?? ??? ?? ???? ??, ?? ?????? ??? ???????
  3. ??????? ????? ?????? ???????? ?????????, ??System.Data???????? ???? ?? ???? ??? ??? ??? ??? ?? ???????? ??? declarations ????? ???? ??? ????? ?? ?? ????? ?? ???? ???System.Data.SqlClient??,System.Data.OleDb, ?? ??? ???? ?? ?? ????? ?? ??? ????
    using System;
    using System.Data;
    using System.Data.SqlClient;
    					
  4. ???? ???? ?? ?? ???? ??????? ?? ??????? ??? ???? ???, ?? ???? ??????? ???????? ???? ?????? ??? ??????? ???????? ??? ??? ????? ???, ??????? ?? ???, ?????????? ID, ?? ??????? ??????? ??????? ??????? ???? ?? ??? ?????? ??????? ??? ?????? ?? ???, ????? ??????? ???????? ????? SQL ????? ?? ??? ?? ?? ??????? ???????? ?? ???:

    OleDb ???????: ?? ???

    ???:?????????? ID <uid>?? ?? ???????? ???? ?? ??? ??????? ????????? ???? ?????</uid> ????????
    Provider=SQLOLEDB.1;User ID=<UID>;Initial Catalog=pubs;Data Source=(local)
    						
    SqlClient ???????: ?? ???
    User ID=<UID>;Initial Catalog=pubs;Data Source=(local)
    						
    ???:??? ???? ?? ???? ?????? ?? ???????? ?? Microsoft ?????? ??????? (MSDN) ????????? ?? "ConnectionString" ?? ??? ???? ??????? ?? ??? ??????? ???????? ????????, ?????:
    HTTP://MSDN.Microsoft.com/en-us/default.aspx
  5. ??? ????? ???? ?? ?? ???? ????? Studio ????? ??Main()?? ??? 1 ?? ??? ?? ????.. ?? ???????? ?? ????? ????, ?? ?? ????????? ??? ???? ??????? ?? ??? ??????? ??????? ???????? ?????? ?????

    ???:?????????? ID <uid>?? ?? ???????? ???? ?? ??? ??????? ????????? ???? ?????</uid> ????????
    class Class1
    {
    	static void Main(string[] args)
    	{
    		string sConnectionString = 
    "User ID=<UID>;Initial Catalog=pubs;Data Source=(local)";
    	}
    }
    					
  6. ?? ??????? ???????? ?? ????? ??, ??? ??? ?????OleDbConnection??,SqlConnection??? ????, ?? ???????? ????????????? ??????? ?? ??? ??? ??????? ??????? ???? ?? ??? ????:
    SqlConnection objConn = new SqlConnection(sConnectionString);
    objConn.Open();
    					
  7. ????? ???SqlCommand??,OleDbCommand????????, ?? ???? ????? ????? ??? ?? ???? ???? ??? ??? ???? ?? ??????? ???????? ??? ???? ????? ????? ??? passes ??? ????? ?? ??? ??:
    string sSQL = "INSERT INTO Employee " + 
      "(emp_id, fname, minit, lname, job_id, job_lvl, pub_id, hire_date) " + 
      "VALUES ('MSD12923F', 'Duncan', 'W', 'Mackenzie', 10, 82,'0877','2001-01-01')";
    SqlCommand objCmd = new SqlCommand(sSQL,objConn);
    					
  8. ?? ?? ?????SqlCommand??,OleDbCommand????????, ?? ??? ?? ???? ???ExecuteNonQuery?? ?? ???????????? ???? ???? ???? ?? ????? ?? ??? ?????? ???ExecuteNonQuery?? (???? ?? DELETE, ??????, ?? ???????? ????? ???) ??? ?? ?????? ???? ???? ???? ?? ??? ????? ???? ??? ??? ????? throwing ???? ??? ???? (????? ????? ???), ???? ??? ?? ?? ????????? ??????????? ??????? ?? ????
    objCmd.ExecuteNonQuery();
    					
  9. ???? ????????? ?? ??????? ????? ???????? ???????? ??,?????????????? ?? ??????? ???? ???? ????? ?????

???????? ?? ????? ???? ????

?? ?? ???? ????? ??????? ?? ??????? (???? ??????, ???????? ????, ?? DELETE ??? ?? ???? ?? ??? ??? ???????? ????????????), ?? ????????? parameterized ????? ???? ???? ?? ??? ????? ????? ???????? ?? ????? ?? ???????? ??????? ????? ??? ?? ?? ?? ???? ??? ?? ????????? ???? ?? ??? ???? ???? ????? ?????? ??? ????? ???? ???? ?? ?? ???????? ??? ?? ??? ???? DELETE ??? ?? ????? ????:
string sSQL = "DELETE FROM Employee WHERE emp_id = @emp_id"
				
???????? ??? ("@ emp_id") DELETE ?? ?? ??? ??? ?? ???????? ?? ?? ???????????? ?? ???? ??? ?? ??? ?? ??? ?? ??? ?? ?? ??????? ????? ??? ?? ???????????? ???? ???

???? ???? ?? ???????? ?? ????? ????, ????? ????? ?? ???? ????:
  1. ????? ????OleDbConnection??,SqlConnection????????, ???? ?? "???? ???? ?? ????? ?? ??? ???? ????"????
  2. ??????????? (?????? ?? ???, "@ emp_id" ?? "@ fname") ?? ??? ??? ????? ???? ???? ???? ??? ???????? ?? ????? ???? ??? ?? ?????? ?? ???, ????? ????? ?? ???? DELETE ???????? ??? ??????
  3. ????? ????OleDbCommand??,SqlCommand????????, ?? ??? ??? ??????? ???????? ?? ????? ??? ?? ???????? ??????????? ??? ???? ??? ??? ???? ???
  4. ???????? ???????? ?? ??? ???? ???????? ?? ???????? ?????? ???? ?? ??? ?? ???????? ???????? ??????? ???????? ???????? ?? ??? ??? ??? ?? ???? ?????? ????????? ???? ?????
    objCmd.Parameters.Add("@emp_id", SqlDbType.Char, 9);
    					
  5. ???????? ???????????? ???????? ?? ??? ???? ?? ???????? ?????? ?? ???? ??? ?????? ?? ???? ?? ???? ?? ???????? ????? ???????? ?? ??? ??? ??? ?? ??? ?? ???? ?????? ???:
    objCmd.Parameters["@emp_id"].Value = "MSD12923F";
    					
  6. ?????? ?? ??? ??? ?????:
    try 
    {
    	objCmd.ExecuteNonQuery();
    }
    catch (System.Exception e) 
    {
    	Console.WriteLine(e.Message);
    }
    Console.WriteLine("Record Deleted");
    					

??? ??????? ?????

???:?????????? ID ????????? ???? ?????? = <uid>??? ??? ?? ??? ?? ?? ??? ?? ????? ?? ????? ????????? ???? ?? <uid>???????. ?? ?? ???????? ???? ?? ??? ??????? ????????? ??</uid></uid>
using System;
using System.Data;
using System.Data.SqlClient;

    /// <summary>
    /// Summary description for Class1.
    /// </summary>
    class Class1
    {
	static void Main(string[] args)
	{
		AddRecord();
		RemoveRecord();
		Pause();
	}

	static void Pause()
	{
		Console.WriteLine("Press Enter To Continue....");
		Console.ReadLine();
	}

	static void AddRecord()
	{
		string sConnectionString = "User ID=<UID>;Initial Catalog=pubs;Data Source=(local)";
		SqlConnection objConn = new SqlConnection(sConnectionString);
		objConn.Open();
		string sSQL = "INSERT INTO Employee " + 
		  "(emp_id, fname, minit, lname, job_id, job_lvl, pub_id, hire_date) " + 
	          "VALUES ('MSD12923F', 'Duncan', 'W', 'Mackenzie', 10, 82,'0877','2001-01-01')";
		SqlCommand objCmd = new SqlCommand(sSQL,objConn);
		try 
		{
			objCmd.ExecuteNonQuery();
			}
		catch (System.Exception e) 
		{
			Console.WriteLine(e.Message);
		}
		Console.WriteLine("Record Added");
	}

	static void RemoveRecord()
	{
		string sConnectionString = "User ID=<UID>;Initial Catalog=pubs;Data Source=(local)";
		SqlConnection objConn = new SqlConnection(sConnectionString);
		objConn.Open();
		string sSQL = "DELETE FROM Employee WHERE emp_id = @emp_id";
		SqlCommand objCmd = new SqlCommand(sSQL,objConn);
		objCmd.Parameters.Add("@emp_id", SqlDbType.Char, 9);
		objCmd.Parameters["@emp_id"].Value = "MSD12923F";
		try 
		{
			objCmd.ExecuteNonQuery();
		}
		catch (System.Exception e) 
		{
			Console.WriteLine(e.Message);
		}
		Console.WriteLine("Record Deleted");
	}
} 
				

??????

ADO.NET, ??????? ????, ?? ???????? ???????????? ?? ????? ???? ???? ?? ???? ??? ???? ??????? ?? ??? ????? Microsoft ??? ???? ?? ????:
SQL Server 2000 ???????? ????????????
(SQL.80) http://msdn2.Microsoft.com/en-us/library/aa214299 .aspx

"??? ???? ??????, diving"MSDN Voices?????
HTTP://msdn2.Microsoft.com/en-us/library/ms810295.aspx

ADO ?????????? ?? ??? ADO.NET
HTTP://msdn2.Microsoft.com/en-us/library/ms973217.aspx

MSDN ?????? .NET ?????? ??????
HTTP://MSDN.Microsoft.com/NET
???? ??????? ?? ???, ????? ???????? ?????:
?????, ???? ?? Jon Jagger.Microsoft Visual C# .NET ??? ?? ???. Microsoft ?????, 2003?
???? ??????? ?? ???, ????? Microsoft ????????? ?? ??????? ????????? ?????:
ADO.NET ?? ??? 2389 ????????????
HTTP://www.Microsoft.com/learning/syllabi/en-us/2389Bfinal.mspx

???

???? ID: 306636 - ????? ???????: 03 ?????? 2010 - ??????: 2.0
???? ???? ???? ??:
  • Microsoft Visual C# .NET 2002 Standard Edition
  • Microsoft Visual C# 2005
??????: 
kbhowtomaster kbsqlclient kbsystemdata kbmt KB306636 KbMthi
???? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:306636

??????????? ???

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com