473,387 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Bound Text box not updating Database

29
I am trying to bind a textbox to a dataset. When I try to use the adapter.update command, nothing in the database update. I feel like I am doing something wrong. Here is my code

Expand|Select|Wrap|Line Numbers
  1.  
  2. 'Fill Computers Table
  3.         Using da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(My.Settings.ComputersSQL, My.Settings.ConnectionString)
  4.             da.MissingSchemaAction = MissingSchemaAction.AddWithKey
  5.             da.Fill(dsHardware, "Computers")
  6.         End Using
  7.  
  8. 'Add DataBinding to Textboxe
  9.         txtDeviceName.DataBindings.Add(New Binding("Text", dsHardware.Tables("Computers"), "Assignment", True, DataSourceUpdateMode.OnPropertyChanged))
  10.  
  11. 'Update the Textbox's value
  12.  
  13.  Using da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(My.Settings.ComputersSQL, My.Settings.ConnectionString)
  14.             Try                           
  15.                 da.Update(dsHardware, "Computers")
  16.             Catch ex As Exception
  17.                 MsgBox(ex.Message)
  18.             End Try
  19.         End Using
  20.  
I can see that the value in the dataset changes. I don't know if it matters but da.UpdateCommand is equal to nothing at the time I call da.Update.
Aug 22 '08 #1
2 1605
Curtis Rutland
3,256 Expert 2GB
Well, your problem is that you are creating a new adapter to update from! You are disposing of your adapter after you bind fields. You need to keep the same adapter. Also, you need to give the adapter an update command.

You might want to look into using SqlDataSource. It makes binding a bit easier.
Aug 22 '08 #2
cday119
29
Alright, that was in the back of my mind but I wasn't quite sure. I'll try it out and tell you what I find.

Thanks
Aug 22 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: rodneybauer1 | last post by:
hello: thanks in advance for any responses. i dont have a isp at home so have to use public library computer. will check this every couple days though. im using visual basic.Net windows XP with...
5
by: Steve Strik | last post by:
My Problem: I have created a database here at work that is exhibiting some very strange behaviour. Essentially the database is structured in a manner where one table is a master record table...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
4
by: gj | last post by:
Hi, I'm trying to update a sql database from a web form using text boxes. I'm trying to learn C# on my own so I am at a complete loss. I created my sql connection, data adapter, dataset and data...
6
by: Frank | last post by:
Hopefully this is the correct group for this message. My previous post to (I assume) a non-.net group was not welcomed. I have a form with 7 text boxes that are all bound to fields of a...
1
by: Spock | last post by:
Hi. I have a form with a listbox and a few label fields all bound to a dataset. When i navigate the listbox the labels change accordingly. so far everything works good. I made a button to...
2
by: Greg | last post by:
I'm using the Framework 1.1, so I don't have access to the new DataGridView object. What I'm wondering is, is there a really simple way to bind a plain datagrid to a database in such a way that...
0
by: Frnak McKenney | last post by:
Can I use a bound ComboBox for both browsing and editing? I'm working on a small, standalone database application using Visual C#.NET 2003 and an Access data file. In order to keep the number...
2
by: =?Utf-8?B?TXIgQg==?= | last post by:
I had originally posted this in another thread, but did not get and results. I appologize for cross posting but I really would like to get some assistance with this. I am new to developing in...
0
by: Mike | last post by:
So here's the situation (.NET 2.0 btw): I have a form, and on this form is a textbox among many other databound controls. The textbox is bound to a field in a data table via the Text property. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.