Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > BOOK: Beginning VB.NET Databases
BOOK: Beginning VB.NET Databases
This is the forum to discuss the Wrox book Beginning VB.NET Databases by Thearon Willis; ISBN: 9780764568008
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning VB.NET Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old April 19th, 2011, 03:35 AM
Registered User
Join Date: Apr 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Beginning Visual Basic .NETDatabase Programming

Dear sir
I started learning programming practice database in the book Beginning Visual Basic. NET Database Programming 2001 but I encountered some errors while trying to add records to the DataTable, and data binding between the text book into DataTable
I used Funtions
Public Function TaoTableDataset(ByRef strConnection As String, ByVal strTablename As String, ByVal _
                  strSQlorStoredProc As String, ByVal Bln As Boolean, ByRef dsDataset As  _
                  DataSet) As DataSet     
        Dim sqlConn As New SqlClient.SqlConnection(StrConn)
            Dim da As New SqlClient.SqlDataAdapter()
            Dim dttb As DataTable = New DataTable(strTablename)
            da.TableMappings.Add("Table", strTablename)
            Dim cmdTable As SqlClient.SqlCommand = New SqlClient.SqlCommand(strSQlorStoredProc, sqlConn)
          If Bln Then
            cmdTable.CommandType = CommandType.StoredProcedure
            cmdTable.CommandType = CommandType.Text
        End If
          da.SelectCommand = cmdTable
         Return dsDataset
    End Function
to created, fill dataset and shows up datagirdviews
      Protected MyBindingManagerBase As BindingManagerBase
      Protected dsData As DataSet
      Private Sub FrmDNCapThe_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim T_SQL As String = "Select * from [DLTHE]"
            Dim bln As Boolean = False
            Dim dsData As New DataSet
            Dim dttb As DataTable = New DataTable("DLTHE")
            dsData = TaoTableDataset(StrConn, "DLTHE", T_SQL, bln, dsData)
            dtgDuLieuThe.DataSource = dsData
            dtgDuLieuThe.DataMember = "DLTHE"
            MyBindingManagerBase = BindingContext(dsData, "DLTHE")
            dtgDuLieuThe.DataSource = dsData.Tables("DLTHE").DefaultView     
      End Sub
but the error occurred in: Binding_Control_Field_datatable()
Sub Binding_Control_Field_datatable()
        Dim dsData As New DataSet      
            Me.txtSoDN.DataBindings.Add(New Binding("Text", dsData, "DLTHE.SODN"))
        txtMaDVi.DataBindings.Add(New Binding("Text", dsData, "DLTHE.Madvi"))
        txtTenDVi.DataBindings.Add(New Binding("Text", dsData, "DLTHE.TENDVI"))
        cboLoaiDT.DataBindings.Add(New Binding("Text", dsData, "DLTHE.LOAIDT"))
        TxtSoLD.DataBindings.Add(New Binding("Text", dsData, "DLTHE.SOLD"))
        cboLoai_DK.DataBindings.Add(New Binding("Text", dsData, "DLTHE.LOAI_DK"))
        txtTuNgay.DataBindings.Add(New Binding("Text", dsData, "DLTHE.TUNGAY"))
        txtDenNgay.DataBindings.Add(New Binding("Text", dsData, "DLTHE.DENNGAY"))
        txtSoTien.DataBindings.Add(New Binding("Text", dsData, "DLTHE.SOTIEN"))
        txtVanBan.DataBindings.Add(New Binding("Text", dsData, "DLTHE.VANBAN"))
        txtSotien_Dong.DataBindings.Add(New Binding("Text", dsData, "DLTHE.SOTIEN_DONG"))
        txtSoDN.DataBindings.Add(New Binding("Text", dsdata, "DLTHE.STT"))
        txtNgayLapPhieu.DataBindings.Add(New Binding("Text", dsdata, "DLTHE.NGAYLAPHIEU"))
        TxtGhiChu.DataBindings.Add(New Binding("Text", dsData, "DLTHE.GHICHU"))
        txtNgay.DataBindings.Add(New Binding("Text", dsData, "DLTHE.NGAY"))
    End Sub
"Child list for field DLTHE cannot be created."

Pleased shows me mistake

Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Basic API Programming ranuji General .NET 1 May 31st, 2005 02:35 AM
beginning visual basic 6 database programming gskarns1 VB Databases Basics 1 September 29th, 2004 10:46 AM
Multithreading Programming in Visual Basic tinku Beginning VB 6 4 March 8th, 2004 01:36 PM
Beginning Visual Basic 6 Database Programming lizardnotebk All Other Wrox Books 1 December 16th, 2003 01:45 PM
Beginning Visual Basic 6 Database Programming mikeceee All Other Wrox Books 0 July 16th, 2003 09:20 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.