Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > Pro VB.NET 2002/2003
|
Pro VB.NET 2002/2003 For advanced Visual Basic coders working .NET version 2002/2003. Beginning-level questions will be redirected to other forums, including Beginning VB.NET.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB.NET 2002/2003 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 March 25th, 2008, 07:18 AM
Authorized User
 
Join Date: Feb 2008
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default What is wrong with this code to add a record?

Hi Please can somebody explain what is wrong with this code, clearly I am not understanding an important issue. I am using XP Sp 2 and Visual Studio 2003 with access databases (office XP).
The form has OleDbConnection1, OleDbDataAdapter1, DsHouses4Sale2
and wizards set-up to Add, Change,Delete.
Clearly my update in code is being 'blocked' by the automatic stuff, how then do I update when using the controls OleDbConnection1, OleDbDataAdapter1, DsHouses4Sale2 on a form? PS in same situation delete is OK.

<code>

Dim cb As New OleDb.OleDbCommandBuilder(OleDbDataAdapter1)
'
' DsHouses4Sale2.Tables("Houses4Sale").Rows(rowcur). Item(3) = newdata
' works when no changes made to its text field on the form txtAddr1.Text
' if changes update not working
' even this DsHouses4Sale2.Tables("Houses4Sale").Rows(rowcur). Item(3) = "newdata"
'
' newdata = InputBox("Input New Value") ' works (no changes to text field)
' newdata = txtAddr1.Text ' no changes made
'
' update the database
'
MsgBox(newdata)
DsHouses4Sale2.Tables("Houses4Sale").Rows(rowcur). Item(3) = newdata
OleDbDataAdapter1.Update(DsHouses4Sale2, "Houses4Sale") ' update access database
StatusBar1.Text = "Updated record details from form: rowcur=" + Str(rowcur) + newdata
'
' Now refresh dataset and data table
'
DsHouses4Sale2.Clear()
OleDbDataAdapter1.Fill(DsHouses4Sale2)
OleDbDataAdapter1.Fill(dt)
rowcur = 0
maxrows = (Me.BindingContext(DsHouses4Sale2, "Houses4Sale").Count - 1)
</code>

Pat
__________________
Pat





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to add new record as first record in dataset hunzian78@yahoo.com ASP.NET 1.0 and 1.1 Professional 4 April 21st, 2006 05:23 AM
FindFirst retrieves wrong record Derek_05 VB Databases Basics 1 March 6th, 2006 01:50 PM
Help with Add record topshed Classic ASP Basics 6 February 7th, 2006 02:59 AM
Combo Box posting to Wrong Record alaxmen Access 1 February 3rd, 2006 12:56 PM
Cannot add new record geolando Access 0 June 27th, 2005 06:23 PM





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