手动初始化dataset并添加表到其中

时间:2020-12-07 19:46:38
Public   Class   MemberTransmit
      Dim   ds   As   New   DataSet ( "Members"   )
      Dim   MemCard   As   DataTable   = ds.Tables.Add(   "MemCard" )
      Dim   Wings   As   Wingsservices. Wingservices   =   New   Wingsservices. Wingservices
      Public   Sub   New ()

          ' 此调用是设计器所必需的。
        InitializeComponent()
          Me .tssLname.Text = cs_login.cs_loginid.Text
          Me .tssLserver.Text = cs_login.aim_server.Text
          ' 在 InitializeComponent() 调用之后添加任何初始化。
          Me .DataGridView1.AutoGenerateColumns =   False
          Me .DataGridView2.AutoGenerateColumns =   False
          Me .DataGridView1.TopLeftHeaderCell.Value =   "序号"
          Me .DataGridView2.TopLeftHeaderCell.Value =   "序号"
        MemCard.Columns.Add(   "MemCardId" ,   Type   .GetType( "System.String" ))
        MemCard.Columns.Add(   "MemCardBuyMan" ,   Type   .GetType( "System.String" ))
        MemCard.Columns.Add(   "MemCardMoney" , System. Type   .GetType( "System.Int32" ))
        MemCard.Columns.Add(   "MemCardName" ,   Type   .GetType( "System.String" ))
        MemCard.Columns.Add(   "MemCardPhone" ,   Type   .GetType( "System.String" ))
        MemCard.Columns.Add(   "MemCardMobile" ,   Type   .GetType( "System.String" ))
        MemCard.Columns.Add(   "MemCardMail" ,   Type   .GetType( "System.String" ))
        MemCard.Columns.Add(   "MemCardAdress" ,   Type   .GetType( "System.String" ))
          Me .DataGridView1.DataSource = ds.Tables( "MemCard" )
      End   Sub

      Private   Sub   btnTran_Click(sender   As   System.   Object , e   As   System. EventArgs )   Handles   btnTran.Click
          Dim   drow   As   DataRow
        drow = MemCard.NewRow
        drow(   "MemCardId" ) = txtMemCardId.Text
        drow(   "MemCardBuyMan" ) = txtMemCardBuyMan.Text
        drow(   "MemCardMoney" ) = txtMemCardMoney.Text
        drow(   "MemCardName" ) = txtMemCardName.Text
        drow(   "MemCardPhone" ) = txtMemCardPhone.Text
        drow(   "MemCardMobile" ) = txtMemCardMobile.Text
        drow(   "MemCardMail" ) = txtMemCardMail.Text
        drow(   "MemCardAdress" ) = txtMemCardAdress.Text
        MemCard.Rows.Add(drow)

      End   Sub