Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics 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 January 12th, 2004, 10:03 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 130
Thanks: 0
Thanked 0 Times in 0 Posts
Default Add New compliling, but not actually adding record

I have a add new, which adds a record to a dataset that I have got to compile, but it is not updating the database at all. After using an addnew upon a table do you have to assign the table to the database again?


Full Code:-

If DialogResult.Yes = MessageBox.Show("You are about to update the database", "Confirm Update", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) Then

            Dim DataScroll As New DataSet
            Dim QScroll As String

            QScroll = "select Message from scrollingmsg"
            myadapter = New OleDb.OleDbDataAdapter(QScroll, myConnection)
            myadapter.Fill(DataScroll, "scrollingmsg")

            Dim TblScroll As DataTable = New DataTable
            TblScroll = DataScroll.Tables("scrollingmsg")

            Dim SurveyRow As DataRow
            SurveyRow = TblScroll.NewRow()

            If DataScroll.Tables("scrollingmsg").Rows.Count - 1 > 0 Then
                SurveyRow = TblScroll.Rows(0)
                SurveyRow.BeginEdit()
                'what you are updating too
                SurveyRow("Message") = TxtScroll.Text
                SurveyRow.EndEdit()
                'Updates Database
                Dim objcommandbuilder As New OleDb.OleDbCommandBuilder(myadapterJobNo)
                myadapter.Update(DataScroll, "scrollingmsg")
            Else
                'Create New Row
                'SurveyRow("Message") = TblScroll.NewRow()
                'what you are updating too
                SurveyRow("Message") = TxtScroll.Text
''''Not working !!!!!!
                TblScroll.Rows.Add(SurveyRow)
            End If
            myadapter.Dispose()
        End If

I know I am doing something stupid, but not sure what

Thanks in advance
Louisa

 
Old January 12th, 2004, 11:15 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

DataSet's are disconnected. You are adding a row to the table, but not updating the source table. Here's an article that has a section on adding new records.

Peter
------------------------------------------------------
Work smarter, not harder.





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to add new record as first record in dataset [email protected] ASP.NET 1.0 and 1.1 Professional 4 April 21st, 2006 05:23 AM
not compliling! habtegiorges C++ Programming 4 September 15th, 2004 01:49 AM
Adding a new record to a dataset Louisa VB.NET 2002/2003 Basics 1 January 14th, 2004 05:33 PM
trouble adding new record TnTandyO Classic ASP Databases 1 November 4th, 2003 02:20 PM
Adding a record using a form cailos Access 2 October 12th, 2003 11:10 PM





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