TO HOW: ????? ?? ????? C# .NET ?? ????? ?? ????? ?? DataSet ?? ?? ????? ????

???? ?????? ???? ??????
???? ID: 320714 - ?? ???????? ?? ?????? ??? ?? ?? ???? ???? ???? ??.
??? ?? ??????? ???? | ??? ?? ??????? ????

?? ????? ??

??????

?? ???? ???? ????? ????? ?? ????? ?? ?? ?? ????? ???? ????DataSet??? ?? ???? ??? ?????????? ???? ?????? ???? ???DataSets, ?????? ?? inheritDataSet????, ?? first-class ????? ????? ???DataSet'sDataTables, ??DataColumns, ????? ???? ?? ????? ???? ?? ??? ??? ???? ??? yielding.

??????????

????? ???? ???????? ?????????, ??????????, ??????? ??????, ???? ?? ????? ?? ?? ????? ?? ???? ???? ?? ??? ???? ??? ???? ?? ??? ???? ??? ?????? ??? ?? ????? ????:
  • Microsoft SQL Server 6.5 (?? ??? ?? ???????) ?? ????????? ???????
????? ???? ?? ???????? ???:
  • Microsoft SQL Server ?? ??? ??????? familiarity
  • Microsoft Visual Studio .NET ?? ??? ??????? familiarity
  • Microsoft ADO.NET ?? ??? ??????? familiarity
  • Microsoft .NET ??? ???????? ?? ??? ??????? familiarity

DataSets ?? ????? ??

Visual Studio .NET ?? ????? ?? ?? ???? ??? ????????? ?? ????? ?? ???, ????? ????? ?? ???? ????? ??? ????????? ????? ?? ?? ?? ?????DataSet????????? ??????? ??? ??? improvised SQL ?????? ?? ?????? ????????? ?????
  1. Visual Studio .NET ?? ??????? ?????
  2. ??? ??? ????????? ????????? ??? ?????TDS??? ????? C# .NET.
  3. ????????? ???? ?? ?????? Explorer ????????? ???? ???? ??? ??? ?????? Explorer ????????? ???? ???? ???? ??, ?? CTRL + ALT + L ??????
  4. ????????? ???? ?? WebForm1.aspx ????? ???? ?? ?????? ????? ??? ??? ??? ????? ???? ???? ??, ??? ?????WebForm1.aspx?????? Explorer ??? ???? ?? ????? ?? ????
  5. ?????? ????? ?? ??? ????? ???????????????? ????? ??? ???? ???? ?? ????
  6. ????? ????? ?? ????? ?? ??? CTRL + ALT + X ?????? ????? ????? ???, ????? ??????? ???????. ?? ??? ???? ?? ????? ????? ?? ????-???? ???? ?? ?? ??????: ???? ???? ?? ???? ??? ????? (???????? ???? ?? ???? ?? ?????) ?? ???? ??? ???????? ?? rows. ?? ??????? ??, ????? ???DataGrid??? ????
  7. ????? ???? ' ????? ????? ??? ????? ????????? ???? ?? ??? F4 ?????? ????????? ??????? ?? ??????? ?? ?????????. ???? ?? ????? ????, ?? ?? ????????? ???? ??????? ?? ??????? ?? ???????.
  8. ??? ??? ????? ?? ???DataSet????????? ?? ??? CTRL + SHIFT + A ?????, ?? ???? ??? ????? ????DataSet???????? ?? ???? ???? ???DataSet?????:dsProducts.xsd. ??? ???? ?? ???? ???? XML ?????? ?????? ??? ??? ????? ????,OK. ?? ?? ?????? ????? ??? ?????? ???? ????? ??????
  9. ????? ?? ?? ????? ?? ???DataSet, ????? Explorer ????? ?? ??? CTRL + ALT + S ??????
  10. ????? ????,?????????? ????,???????? ?? ???????? ????,SQLServers????? ????,????? ???????? ????,??????????? ????-????? ????, ?? ???? ????????.
  11. ????????? SQL Server ????? ?? ??? ???????????? ?? ???????? ????, ?? ???? ??? ????? ?????? ???? ???? ?? ??? ??????DataSet?????? ????? ?? ???? ?? ????? ???? ??? ?? ?? ?????? ??? ?? ?? ????? ???????????? ????? ?? ????? ???? ??? XML ?????? ????? ?? ??? ???????? ?? ????? ?? ??? ????? ????XML??? ?????? ????? ?? ??????? ???
  12. ??? ?????? ?? ???? ?? ???? SQL ????? ???????? ?? ????? ??? ????? ?? ????? ?? ?? ???? ?? ???DataSet???? ?? ?????? ?? ??? ???? ????? ???? ????? ?????? ????? ?? ????-????? ????, ?? ???? ??? ????????? ???? ?? ??DataSet ????? ?????????? ????? ??? ??? ?? ????? ???? ??, ???? ??? ????? ?????? ?? ?????? ?? ???? ????? ?? ??? CTRL + S ??????
  13. ??? ????? ?? ??? ???? ???DataSet????, ????? ??????? ??????? ????????? ?????? Explorer.
  14. ???? ?? ??? ???? ?? ??????? ????dsProducts.xsd. ?? ???? dsProducts.vb ????, ?????? ?????? ?? ??? ??? ???? ?????? ?????? ?? ?? ???? dsProducts.xsx ????, ?????? ??????? ?? ??? ???????? ????? ???? ?? ??? ????? ???? ???? ?? ??????
  15. ??? ?? ????? ?? ????????? ???? ?? ??? ????? ?? ???DataSet, ??? ??????? (???? ?? ??? ??? ????????) ?? ???-????? ????? ??????? ????? ?? ????? ??, ?? ??? ??????? codebehind ????? ???? ??Page_Load??????
  16. System.Data.SqlClient ??? ????? ??? ???? ???? ???? ?? ????? ???? ?? ??? ????? ???????? ????? ??????? codebehind ?? ????? ??:
    using System.Data.SqlClient;
    					
    ???:: ???? ???????? ?? ???? ?? ???? ??? ????????? ?? ??? ???? ??? ???? ?? ??? ????????? ??? ???????? ???????? ??? ?? ??? ??? ?? ?? Visual Studio .NET ??? ???? ??? ????????? ????? ????

  17. ?????Page_Load????? ?????????, ??????? ???????? ?? ??????? constructor ??? ?? ??? ?? ?? ??? ??????? ???????? ?? ?????SqlConnection????:
    SqlConnection cn = new SqlConnection("server=myserver;uid=myuid;pwd=mypassword;database=northwind");
    					
  18. ???? ??? SqlDataAdapter ???????? ?? ??? ???? ??? ?? ?? SqlCommand ???????? ?????? SqlCommand constructor ???? ?? ??? ??? improvised SQL ??? ?? ?? ??????? ???????? ??? ????? Former ??? ???? ??CommandText??? SqlCommand ???????? ?? ???? ?? ???? ???????? ????????? ?? ??? ?? ??? ?? ???? ????
    SqlCommand cmd = new SqlCommand("select * from [Alphabetical list of products]", cn);
    					
  19. ??? SqlCommand ???????? constructor ??? ?? ??? ?? SqlDataAdapter ????????, ?? ??????? ?????:
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    					
  20. ?? ?? ??????? ?? ?????? ?? ?? ???? ?? ???? ???? ?? ??? ?????? ???????? ????? ???? ????? ?? ??? ?? ????? ?? ?? ???DataSet. ????? ??? ?? ?? ???????dsProducts???? ????? ??? ??: ?? dsProducts ?????? ?? ??? ?? ?? inherits ????DataSet????, generic ????DataSet???? ??????
    dsProducts tds = new dsProducts();
    					
  21. ???????? ??? ??? ????? ?? ?? ??? ??, SqlDataAdapter ????DataSet???????? ??DataSet???? ?????? ???? ??? ??DataTable TableName???:
    da.Fill(tds, tds.Tables[0].TableName);
    					
  22. ??? ???? ?? ???????????? ????? ?? ??????? ??? ????? ?? ??? ????? ???????? ?? ???DataSet'sDataTable, ????? ?????? ?? ????? ????:
    dsProducts.DataTableName[RowIndex].ColumnName
    						
    ?? ????? ????????? ?? ??? RowIndex ?? ?????-coded 5 ?? ???:
    TextBox1.Text = tds.Alphabetical_list_of_products[5].ProductName;
    TextBox2.Text = tds.Alphabetical_list_of_products[5].CategoryName; 
    						
    ?????????????????? ????? loads, ??? ??? ????? ???????? ?? ??? ?????? ??? ?????? ?? ?????? ???? ?? ??? ????????? ?????? zero-based, ??DataGrid.
  23. ??? ??? ?????? ????????? ???? ?? ???DataGrid, ??? ???????? ???????? ???? ?? ??? DataGrid ?? ??? ???? ?????? ???? ??? ??DataSet, ?? ???DataBind():
    DataGrid1.DataSource = tds;
    DataGrid1.DataBind();
    					

??? (WebForm1.aspx) ?? ???? ?? ???? ????

<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="TDS.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
	<title>WebForm1</title>
	<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
	<meta name="CODE_LANGUAGE" Content="C#">
	<meta name="vs_defaultClientScript" content="JavaScript">
	<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
	<form id="Form1" method="post" runat="server">
		<asp:Label id="Label1"  runat="server" >Label</asp:Label>
		<asp:DataGrid id="DataGrid1"  runat="server" ></asp:DataGrid>
		<asp:TextBox id="TextBox2"  runat="server"></asp:TextBox>
		<asp:TextBox id="TextBox1"  runat="server"></asp:TextBox>
		<asp:Label id="Label2"  runat="server" >Label</asp:Label>
	</form>
</body>
</HTML>
				

??? (WebForm1.aspx.cs) ?? ???? ?? ???? ????

using System.Data.SqlClient;

namespace TDS
{
  /// <summary>
  /// Summary description for WebForm1.
  /// </summary>
  public class WebForm1 : System.Web.UI.Page
  {
    protected System.Web.UI.WebControls.Label Label1;
    protected System.Web.UI.WebControls.Label Label2;
    protected System.Web.UI.WebControls.TextBox TextBox1;
    protected System.Web.UI.WebControls.TextBox TextBox2;
    protected System.Web.UI.WebControls.DataGrid DataGrid1;
	
    private void Page_Load(object sender, System.EventArgs e) 
    {
	SqlConnection cn = new SqlConnection("server=localhost;uid=sa;pwd=abcd;database=northwind");
	SqlCommand cmd = new SqlCommand("select * from [Alphabetical list of products]", cn);
	SqlDataAdapter da = new SqlDataAdapter(cmd);
	dsProducts tds = new dsProducts();

	da.Fill(tds, tds.Tables[0].TableName);
	TextBox1.Text = tds.Alphabetical_list_of_products[5].ProductName;
	TextBox2.Text = tds.Alphabetical_list_of_products[5].CategoryName; 

         DataGrid1.DataSource = tds;
	DataGrid1.DataBind();

    }

    #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
	// 
	// CODEGEN: This call is required by the ASP.NET Web Form Designer.
	// 
	InitializeComponent();
	base.OnInit(e);
    }
		
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {    
	this.TextBox1.TextChanged += new System.EventHandler(this.TextBox1_TextChanged);
	this.Load += new System.EventHandler(this.Page_Load);

    }
    #endregion
  }
}

				

?????????

??? ????????? ?? ????? ?? ??? F5 ?????? ??????? ??? "Uncle Bob ?? Organic Dried Pears" ????????? ???? ??????????? ????? ?? "???" ?????? ??????????? ????? ???? ?????? ??????? ?? ??? ?? ?? ???? DataGrid ??? ????? ?? ??????? ????? ???? ???

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

  • GenericDataSets?? ???????? ???? ???? ?? ???? ??? ???TableName?? ?? ???????????? ??? ???? ?????? ???? ???DataSets, ??? ??, ???????? ??, ??? ?? ?? ??????? ???DataSet's???????????? ?? ???? ????????????? ??????TableName. ?????? ?? ????? ?? ??? ???? ?? ???DataSet'sTableName?????? ?? "?? ??? ?????? ?? ?????? 0" ?????? throws ????? ?? ???????? ?? ???? ?????? ???? ??? ??DataSets?? ???? ?? ?? ?? ???? ????? ????TableName????? ???????? ?? ?? ??? ?????? ??? ????? ??DataSet????, ?? ????? ??? ??? ?? ??? ??? ?????? ???? ???
  • ??? ?? ?? ?? ?????? ????? ???? ?? ??? ???????? ?????? ???? ???? ?? ?? ???? ?????? ???? ??? ??????? ???????? ?? ????? Visual Studio .NET ?????? ??????? ?? ?? ?? ?? ?????? ?? ??? ???? ?? ??? ?? ???????? ???????? ???????? ?? ??? ???DataSet????, ?? ?????? ?????? ????? ?? ??? ???: ??????? ???? ??? ???? ?? ??? Microsoft SQL Server ???? ?? ?? ?? ??? ????? ???? ?? ??? ???? ?? ???????? ???? ?? ??? ?????????? preferable ??DataSet?? ????? ???? ?? ??? ??????? ?????? ????????? ?????

??????

????? ?? ?? ?? ??? ????? ???? ?? ???? ??? ???? ??????? ?? ???DataSet, ????? Microsoft ??? ???? ?????:
(vs.71) http://msdn2.Microsoft.com/en-us/library/esbykkzb .aspx


???

???? ID: 320714 - ????? ???????: 04 ?????? 2010 - ??????: 2.0
???? ???? ???? ??:
  • Microsoft ADO.NET 1.1
  • Microsoft Visual C# .NET 2002 Standard Edition
  • Microsoft Visual C# .NET 2003 Standard Edition
??????: 
kbhowtomaster kbmt KB320714 KbMthi
???? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:320714

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

 

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