HOW TO: ??????? ???? ??????? ????? ???? ?? ??? Managed ????? ?? Visual C# .NET

?????? ????????? ?????? ?????????
???? ???????: 313304 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

?????? ??? ???? ???? ????? ?????? ??? ????? ??????? ???? ?????? ?????? ??? ???? ?? ???????? ???? ??? ???????.

??? ?????

??? ADO.NET ????? ?????? ?? ????? ???????? (??? ???? ??????? SqlClient ? OleDb ? ODBC ?????). ?? ???? ?????? ???? ?????? .NET ??? ???? ??? ????? ????? ????? ????? ???????? ?????? ?? ?? ???? ?????? ????? ????????? ???????? ???? ????. ????? ??? ???????? ????? ??????? ???? ??????.

??? ???? ??????? ??? ?????? SqlDataAdapter ? OleDbDataAdapterOdbcDataAdapter ???? ?? ??? DbDataAdapter ??? ??? ?? ??? System.Data.Common.DataAdapter ?????. ????? ????? ??? ?? ?????? ???? ?????? ??? ????? (DataAdapter) ?????? ??? ????? ?? ??? ?????? (??? SqlDataAdapterOleDbDataAdapter ? OdbcDataAdapter). ???? ?????? ?????? ???? ??????? ?? ????? ???? ??????. ???? ???????? ???? ??? ?????? ????? ????? ???? ???? ?? ??? ?? ???? ??????? ???? ???? ??? ???? ?????.

?????? ??? ??????? ?????? ??? ????? ?? Visual C# .NET ???? ??? ??? ??????? ????? ?????? ?? "????? ??????? ?? Microsoft:
307205HOW TO: ??????? ????? ?? C#
???? ??????? ??????? ?? ??? ??????? ????? ??????? ????? IDataAdapter ????? ?? ???? .NET ????? DataAdapter.

??????: ???? ????? ?????? ??? ????????? ???????? ???? ??????? ????? IDataAdapter ??? ??? ?? ??? DbDataAdapter. ???? inclue ?????? ?????? IDBConnectionIDBCommand ? IDataReader.

???????

??????? ??????? ??? ??????? ?????? ??? ? ?????? ? ?????? ???????? ?????? ? ???????? ? ????? ? ??? ??????? ???:
  • ????? Microsoft Windows 2000 Professional ?? ???? ??????? Microsoft Windows 2000 Server ?? ???? ??????? Microsoft Windows 2000 Server ?? Microsoft Windows NT 4.0 Server
  • Microsoft Visual Studio .NET
  • ???? ?????? .NET ODBC
  • Microsoft SQL Server 7.0 ?? ??????
??????? ??????? ??? ???? ??? ??? ?????? ???????? ????????? ???????? ?? ??? ???????.
  • Microsoft Visual Studio .NET
  • ??????? Microsoft ADO.NET ????? ??????

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

???? ?????? ?????? ????? ??????? ????? IDataAdapter ?????? ???? ?? System.Data.OleDb.OledbDataAdapter ? System.Data.SqlClient.SqlDataAdapter ? Microsoft.Data.Odbc.OdbcDataAdapter ????????? ????????.
  1. ??? ????? Visual Studio .NET.
  2. ????? ????? Windows ???? ?? Visual C# .NET.
  3. ???? ?? ?? ????? ??????? ??? ???? ??? ????? ????? System.Data; ????? ???? ??? ?? ???.
  4. ????? ????? ??? Microsoft.Data.Odbc.dll.?????? ??? ??????? ?????? ??? ?????? ??????? .NET ODBC ???? ??? ??? ??????? ????? ?????? ?? "????? ??????? ?? Microsoft:
    310988HOWTO: ??????? ???? ????? .NET ODBC ?? Visual C# .NET ? ????? ???????
  5. ??? ?? ? DataGrid ????? ????? ???? RadioButton Form1.
    • ????? ????? ??? ???? ??? btnTest ???????? ???? ??? ??????.
    • ????? ????? ????? ????? RadioButtonrbSqlClient ?? ??????? Text ??? ???? SQL.
    • ????? ????? ????? ?????? RadioButtonrbOledb ?? ??????? Text ??? OLEDB.
    • ????? ????? ??? ?????? RadioButtonrbOdbc ?? ??????? Text ??? ODBC.
  6. ?????? ??????? ???????? ??? ?????? ??????? ???? ??? ?????? ????? ????????? ?? ????? ??????? ?????? ?? ????????? ????????. ????? ????????? ???????? ??????? ??? ???? "Declarations ???" Form1:
    using System.Data;
    using System.Data.Common;
    using System.Data.OleDb;
    using System.Data.SqlClient;
    using Microsoft.Data.Odbc;
    					
  7. ???? ?? ???? ???????? ???????? ??????? ?? ????? "Declarations ???":
    IDataAdapter da;
    DataSet ds = new DataSet();
    					
  8. ????? ???? DataAdapterFactory ????? ??? ????????? ???????? ???????:
    public IDataAdapter DataAdapterFactory()
    {
    	String myConnString; 
    	String myQuery  = "Select * From Customers";
    
    	if (rbSqlClient.Checked)
    	{
    		//Using SqlClient
    		myConnString = "server=myserver;integrated security=sspi;database=Northwind";
    		SqlConnection mycon = new SqlConnection(myConnString);
    		SqlDataAdapter daCust = new SqlDataAdapter(myQuery, mycon);
    		return daCust;
    	}
    	else if (rbOledb.Checked)
    	{
    		//Using OleDb
    		myConnString = "Provider=SqlOledb.1;Data Source=myserver;integrated security=SSPI;Database=Northwind";
    		OleDbConnection mycon = new OleDbConnection(myConnString);
    		OleDbDataAdapter daCust = new OleDbDataAdapter(myQuery, mycon);
    		return daCust;
    	}															   
    	else if (rbOdbc.Checked)
    	{
    		//Using Odbc
    		myConnString = "Driver={SQL Server};Server=myserver;trusted_connection=yes;database=Northwind";
    		Microsoft.Data.Odbc.OdbcConnection mycon = new Microsoft.Data.Odbc.OdbcConnection(myConnString);
    		OdbcDataAdapter daCust = new OdbcDataAdapter(myQuery, mycon);
    		return daCust;
    	}
    	else
    	{
    		return null;
    	}																											  
    }
    					
  9. ???? ?? ???? ???????? ???????? ??????? ?? ????? ???? btnTest:
    da = DataAdapterFactory();
    da.Fill(ds);
    dataGrid1.DataSource = ds ;
    					
  10. ????? ????? ????? ??? ?? ????? ?????.
  11. ??? ??????? ????? ??. ?? ??????? ????? ? ???? ??? ???? ????? ???????.
  12. ????? ???? ??????? ???? ???? ??????? ??????? ?? ???? ??? ?? (??????).

    ???? DataGrid ???????? ???? ?? ??????? ?? ?????????.

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

??? ??? ?????? ???? ?????? ?? ???? ??????? ????? ?????.

?????

?????? ??? ???? ?? ????????? ??? ?????? ADO.NET ???? ???? ???? ????? SDK Framework Microsoft .NET ?? MSDN ??? ??????:
?????? ??? ???????? ???????? ADO.NET
http://msdn.microsoft.com/en-us/library/e80y5yhx(vs.71).aspx
?????? ??? ???? ?? ????????? ??? ????? .NET ??????? ???? ???? ?????? .NET ?? ???? Microsoft ?????? ??? ?????:
???? .NET ????? ?????
http://msdn.microsoft.com/en-us/library/ms810268.aspx

???????

???? ???????: 313304 - ????? ??? ??????: 26/???? ??????/1428 - ??????: 3.4
????? ???
  • Microsoft ADO.NET 1.0
  • Microsoft ADO.NET 1.1
  • Microsoft Visual C# .NET 2002 Standard Edition
  • Microsoft Visual C# .NET 2003 Standard Edition
????? ??????: 
kbmt kbhowtomaster kbsqlclient kbsystemdata KB313304 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????313304

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

 

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