????? ????? ?????? ????? Windows ????? ?????? ?? Visual Studio .NET ?? ?? Visual Studio 2005

?????? ????????? ?????? ?????????
???? ???????: 315838 - ??? ???????? ???? ????? ????? ??? ???????.
??? ????? ??? ???????. ????? "??? ??" ??? ??? ??????? ??? ????.
????? ???? | ?? ????

?? ??? ??????

??????

???? ??? ?????? ????? ????? ????? Windows ????? ?????? ????????. ?? ????? ??????? ??????? ?? Visual Basic .NET ?? ?? Visual Basic 2005. ?????? ??? ??????? Visual Basic Visual C# "??? ?????" ???? ?????? ????? ????? ?????? ???????? ???????.

???????

???? ??????? ??????? ??????? ?????? ??? ????? ?????? ???????? ?????? ? ??? ??????? ???? ???????:
  • Microsoft Windows 2000 Professional ?? ???? ??????? Microsoft Windows 2000 Server Microsoft Windows XP Professional ?? Microsoft Windows XP Server ?? Microsoft .NET Framework ???????
  • ???? ???????? ?? Microsoft "(MSDE) ?? Microsoft SQL Server 7.0 ?? ??????? ?????? ?? ????? ?????? Northwind
????? ??? ??????? ??? ??????? ??? ???????? ???????:
  • ????? ???????
  • ????? Windows
  • Microsoft ADO.NET

????? ????? Windows ????? ??????

???? ??????? ??????? ????? ????? ??????? Windows ????? ?????? ????????. ??? ????? ??? ?? "? ????? ??? ???? ???????? ?? ????? ???????? Northwind ?? ???? ???? DataGrid.
  1. ????? ????? Visual Basic ????? Windows ??? ???:
    1. ??? ????? Microsoft Visual Studio .NET ?? Microsoft Visual Studio 2005 ?? ???? ??? ????? ????.
    2. ??? ????? Project ? ???? ??? ?????? Visual Basic. ??? ????? ? ???? ??? ????? Windows. ????? ????? ??????? MultiLangHowTo ?? ???? ??? ?????.

      ?????? ?? Visual Studio 2005 ? ???? ??? Visual Basic ??? ????? Project.
  2. ???? ?? ???? ???? "?????? ??????". ??? ?? ??? ????? ???? ??? ?????? ?????? ?? ??????? ???.
  3. ???? ???? shell ????? Visual Basic .NET ?? ????? Windows 2005 Visual Basic ???? ?? ?????? MultiLangHowTo. ???? ??? ?? ????? ?????? ??? ????? Visual C# "??? ?????".

    ?? ???? "?????? ??????" ? ???? ??? ?????? ?????? ??? MultiLangHowTo ? ??? ??? ????? ? ?? ???? ??? ????? ????. ??? ????? Project ? ???? ??? Visual C# ????????. ??? ????? ? ???? ??? ????? ??????. ????? ????? ????? ??? NWClassLib. ???? ??? ????? ?????? ??? "????? ??????" ??? ????.

    ?????? ?? Visual Studio 2005 ? ???? ??? Visual C# ??? ????? Project.
  4. ???? Class1.cs ?? ???? ????. ????? ??????? ????? ????? ??????? ??? ???? ??? ??????. ????? ??? ????????? ?? ?????? ??? ???? ????? ???? ???? ????? ?????? ???? DataSet.
    using System.Data;
    using System.Data.SqlClient;
    					
  5. ??????? ????? Class1 ???????? ???????? ?????? ???? ???? ?????? ????? DataSet ?? ???? ???????? ?? ?????? ?????? Northwind:
    public static DataSet GetProducts()
    {
       DataSet ds = new DataSet();
       SqlDataAdapter sqlDS = new SqlDataAdapter(
          "select * from products", new SqlConnection(
          "server=(local);database=northwind;Integrated Security=SSPI"));
       sqlDS.Fill(ds);
       return ds;
    } 
    						
    ??????: ?? ????? ???? ???? ????? ????? ????? SQL ??????. ?? ???? ???? ?????? ????? ????? ??????.
  6. ????? ???? ????? ????? Windows Visual Basic ??????? ???? ??? ?????? ??? ??????. ??? ?? ???? Form1.vb ?????? ?????? ?? Design View. ??? ?? ??? ???? ????? ??????? ??? Form1.vb ?? ???? "?????? ??????".
  7. ????? ???? ???? ?? ????? ???? DataGrid ??? ??????? ??? ???:
    1. ?? ??????? ???? ???? ??? ???? ????? ???? ???? ???????. ???? ????? ????? ??? CTRL + ALT + X ????? ?????? ???? ???? ???????.
    2. ?? ???? ????? ?????? ? ???? ??? ????? Windows.
    3. ????? ???? ???? ?? ??? ???????.
    4. ???? ??????? F4 ?????? ??? ???? ??????? ????? ?????? ??. ????? ??????? Text ??? ????? ????????.
    5. ????? ???? ???? DataGrid ??? ???????.
  8. ?? ?????? ???? ??????? ???? NWClassLib ??? ???:
    1. ?? ???? "?????? ??????" ??? MultiLangHowTo ???? ??? ?????? ?????? ??? ????? ??? ?? ???? ??? ????? ????.
    2. ??? ????? ??????? "????????" ? ???? ????? ??????? ??? NWClassLib. ???? ???? NWClassLib ?? ???? ??????? ???????? ???????.
    3. ???? ??? ?????. ???? ???? NWClassLib ??? ????? ?????? Windows.
  9. ???? ????? ??????? ??? ????. Visual Studio .NET ???????? ?????? ????? ??? ?????. ????? ????????? ???????? ??????? ??? ????? ??????? ???:
    Dim objNW As New NWClassLib.Class1()
            DataGrid1.DataSource = objNW.GetProducts.Tables(0)
    					

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

???? ????? ??? Class1.cs

using System;
using System.Data;
using System.Data.SqlClient;

namespace NWClassLib
{
    /// <summary>
    /// Summary description for Class1.
    /// </summary>
    public class Class1
    {
        public static DataSet GetProducts()
        {
            DataSet ds = new DataSet();
            SqlDataAdapter sqlDS = new SqlDataAdapter(
                "select * from products", new SqlConnection(
                "server=(local);database=northwind;Integrated Security=SSPI"));
            sqlDS.Fill(ds);
            return ds;
        } 
    }
}
				

???? ????? Class1.cs

using System;
using System.Data;
using System.Data.SqlClient;

namespace NWClassLib
{
    /// <summary>
    /// Summary description for Class1.
    /// </summary>
    public class Class1 : System.Windows.Forms.Form
    {
        public static DataSet GetProducts()
        {
            DataSet ds = new DataSet();
            SqlDataAdapter sqlDS = new SqlDataAdapter(
                "select * from products", new SqlConnection(
                "(local);database=northwind;uid=sa"));
            sqlDS.Fill(ds);
            return ds;
        }
    }
}
				

System.Windows.Forms.Form ????? Form1.vb

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'The Windows Form Designer requires this call.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call.

    End Sub

    'Form overrides Dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'The Windows Form Designer requires this code.
    Private components As System.ComponentModel.IContainer

    'The Windows Form Designer requires this procedure.
    'You can use the Windows Form Designer to modify it. 
    'However, do not use the Code editor to modify it.
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Button1 = New System.Windows.Forms.Button()
        Me.DataGrid1 = New System.Windows.Forms.DataGrid()
        CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(24, 16)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(96, 23)
        Me.Button1.TabIndex = 0
        Me.Button1.Text = "Show Products"
        '
        'DataGrid1
        '
        Me.DataGrid1.DataMember = ""
        Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.DataGrid1.Location = New System.Drawing.Point(24, 48)
        Me.DataGrid1.Name = "DataGrid1"
        Me.DataGrid1.Size = New System.Drawing.Size(256, 200)
        Me.DataGrid1.TabIndex = 1
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 266)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.DataGrid1, Me.Button1})
        Me.Name = "Form1"
        Me.Text = "Form1"
        CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
        Dim objNW As New NWClassLib.Class1()
        DataGrid1.DataSource = objNW.GetProducts.Tables(0)
    End Sub
End Class
				
?????? ??? ????? ????????? ???????? ?? Visual Basic 2005. ???? ???????? ????? Visual Basic ????? ??????? ??? ????? ?????? ????? ????? Windows. ??? ?? ????? ??????? Form1, ??? ????? ??????? ???? ???? ??????? Form1.vb ? Form1.Designer.vb. ????? ????????? ???????? ?? ??? Form1.vb. ???? ????? Windows ?????? ???????? ???????? ?? ??? Form1.Designer.vb. ???? ????? Windows ?????? ?????? ???????? ??????? ?????? ????? Form1 ??? ????? ??????. ???? ??? ?????? ?? ????????? ???????? ???? ?? ??????? ???? ?? ??? interspersed ?? ????????? ???????? ?????? ??.

????? ?? ????????? ??? ??????? ????? 2005 Visual Basic ??????? ?? ?????? ???? ???? ????? Microsoft (MSDN) ?????? ??? ?????:
http://msdn2.microsoft.com/en-us/library/ms379584(vs.80).aspx
????? ?? ????????? ??? ???? ????? "?" ???? ????? Windows ?? ?????? ???? MSDN ??????:
http://msdn2.microsoft.com/en-us/library/ms171843.aspx

NWClassLib.Class1 ????? WebForm1.vb

Public Class Form1
    Inherits NWClassLib.Class1

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'The Windows Form Designer requires this call.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call.

    End Sub

    'Form overrides Dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'The Windows Form Designer requires this code.
    Private components As System.ComponentModel.IContainer

    'The Windows Form Designer requires this procedure.
    'You can use the Windows Form Designer to modify it. 
    'However, do not use the Code editor to modify it.
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Button1 = New System.Windows.Forms.Button()
        Me.DataGrid1 = New System.Windows.Forms.DataGrid()
        CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(24, 16)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(96, 23)
        Me.Button1.TabIndex = 0
        Me.Button1.Text = "Show Products"
        '
        'DataGrid1
        '
        Me.DataGrid1.DataMember = ""
        Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.DataGrid1.Location = New System.Drawing.Point(24, 48)
        Me.DataGrid1.Name = "DataGrid1"
        Me.DataGrid1.Size = New System.Drawing.Size(256, 200)
        Me.DataGrid1.TabIndex = 1
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 266)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.DataGrid1, Me.Button1})
        Me.Name = "Form1"
        Me.Text = "Form1"
        CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
        'Dim objNW As New NWClassLib.Class1()
        DataGrid1.DataSource = GetProducts.Tables(0)
    End Sub
End Class
				

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

  1. ???? ??????? F5 ?????? ??????? ?? ??? ???????.
  2. ??? ???? "???????" ? ???? ??? ????? ????????. ???? DataGrid ???? ???????? ?? ?????? ?????? Northwind.
  3. ???? ?????? ???????? SHIFT + F5 ????? ????? "?" ?????? ??? Visual Studio.

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

?????? ????? ????? ?????? ??? ????? ??????? ??????. ????? ?? ????? ???? ?? "????? ??????" ??????? ??????? ??? ???.

??? Form1 ??? ?????? ?? ??? System.Windows.Forms.Form. ???? ?? ????? Microsoft .NET ????? ?????? ??? ???? ??? ????? ????? Windows.Forms.Form ??? ??? NWClassLib.Class1 ????? ???? "????? ??????".

??????: ??? ??????? n ????????? ??????? ????? ?? ??? ??? ????? ?????? ?? ???? ?????? ??????. ??? ???? ????? ????? ????? ??? ??? ??? ??? ??? ???? ????? ???? ????? ?????? ??????.
  1. ????? ???? ??? ????? ????? System.Windows.Forms.Form ?? "????? ??????" ??? ????? ?? Visual C# ????????? ????????.
  2. ?? ???? "?????? ??????" ??? NWClassLib ???? ??? ?????? ?????? ??? ????? ??? ?? ???? ??? ????? ????.
  3. ??? ????? ??????? .NET ? ???? ????? ??????? ??? System.Windows.Forms.dll. ???? ???? System.Windows.Forms.dll ?? ???? ??????? ???????? ???????.
  4. ???? ??? ?????. ???? ???? System.Windows.Form ??? ????? ?? ???? "????? ??????".
  5. ????? ????? Class1 ?? ??? ????? ?????:
    public class Class1 : System.Windows.Forms.Form
    					
  6. ??? Visual Basic .NET ?? Visual Basic 2005 Form1 ???? ???? ?? ??? Class1. ???? ??? Class1 ??? System.Windows.Forms.Form ? ??? MultiLangHowTo.Form1 ????? ??? System.Windows.Forms.Form ???? ??????? ????? ?? ?? Class1.

    ?? ???? "????" ? ???? ??? Form1.vb. ??? ????? ??? ??????? System.Windows.Forms.FormNWClassLib.Class1. ??? ?? ???? ??? ??????? ??? ???:
    Inherits NWClassLib.Class1
    					
  7. ??????? ?????? ????? ????? ?? ????? ??????? ???? ??? ???:
    'Dim objNW As New NWClassLib.Class1()
    						
    ??????: ????? ????? ??? ?????? ??? ???? ??? ?? ???? ??? ????? ?????? ?????? ??????? ??? ???? ????? ??????? ?????? ??? ?? ????????? ????????.
  8. ????? ????? ?????? ??? ???:
    DataGrid1.DataSource = GetProducts.Tables(0)
    					
  9. ??? ??????? ?? ?????? Verify That It Works.

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

  • ??? ????? ?? ????? ??? ????? ???? ??? ???? ??????. ?? ???? Visual C# ???? ?????? ???? ???? ?????. ????? ??? ???? ????? ????? Visual C# .NET ??? ????? ???? ?? ??????? ??? ???? ????? ??? Visual Basic .NET. ???????? ??? ???????? ????????? ???? ??? "??? ???????" ?? Microsoft .NET Framework ????? ?????? ??????? (SDK):
    ??????? ?????
    http://msdn2.microsoft.com/en-us/library/czz35az4(vs.71).aspx
  • ??? ??? ???? ?? ??????? ????? ????? ?????? ????? ????? ????? ?? ?? ???? ???????? ????? ??????? ??????. ??? ????? ?? ??? ????????? ???????? ?? ????? ????? ???? ????? ??? ??? ?? "????? ??????". ?? ??? ?????????? ?? ??? ??????? ??????? ?? "????? ??????" ????? ?????? ??????. ??? ???? ??????? ???? ????? ???? ??? ??????? MultiLangHowTo ?? ??????? NWClassLib. ???? ????? ????? ???????:
    ???? ????? ???? ??? 'MultiLangHowTo'. ???? ????? ??? ??????? ????? ????? ??????.

?????

????? ?? ?????????? ???? ??? ????? Microsoft ??????? ??? ?????:
Instincts ????????: ??????? ????? ?? .NET ??? 1
http://msdn.microsoft.com/en-us/magazine/cc135806.aspx

Instincts ????????: ??????? ????? ?? .NET ??? 2
http://msdn.microsoft.com/en-us/magazine/cc301744.aspx

???????

???? ???????: 315838 - ????? ??? ??????: 28/???? ??????/1435 - ??????: 4.8
????? ???
  • Microsoft Visual Basic 2005
  • Microsoft Visual Basic .NET 2003 Standard Edition
  • Microsoft Visual Basic .NET 2002 Standard Edition
  • Microsoft Visual C# .NET 2003 Standard Edition
  • Microsoft Visual C# .NET 2002 Standard Edition
????? ??????: 
kbnosurvey kbarchive kbmt kbvs2005swept kbvs2005applies kbhowtomaster KB315838 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????315838

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

 

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