Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > BOOK: Beginning VB.NET Databases
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
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
Code:
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)
        sqlConn.Open()
            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
        Else
            cmdTable.CommandType = CommandType.Text
        End If
          da.SelectCommand = cmdTable
          da.Fill(dsDataset)      
         Return dsDataset
    End Function
to created, fill dataset and shows up datagirdviews
Code:
      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")
            
            Binding_Control_Field_datatable()           
            dtgDuLieuThe.DataSource = dsData.Tables("DLTHE").DefaultView     
           
      End Sub
but the error occurred in: Binding_Control_Field_datatable()
Code:
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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 12:36 PM
Beginning Visual Basic 6 Database Programming lizardnotebk All Other Wrox Books 1 December 16th, 2003 12:45 PM
Beginning Visual Basic 6 Database Programming mikeceee All Other Wrox Books 0 July 16th, 2003 09:20 AM



All times are GMT -4. The time now is 01:22 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.