473,387 Members | 1,791 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.

Updating Data

I have the following code to populate some textboxes on a form. This query
only brings in one record.

strSQL = "Select * from Contact WHERE sysID = '" & g_sysID & "'"

Dim DA As New SqlClient.SqlDataAdapter(strSQL, CN)

DA.Fill(objDS, "Contact")

Me.txtFirstName.DataBindings.Add("Text", objDS, "Contact.first_name")

Me.txtLastName.DataBindings.Add("Text", objDS, "Contact.Last_name")

Me.txtPhone.DataBindings.Add("Text", objDS, "Contact.Phone1")

and I want to update the fields when I am finished. What is the best way to
update? I tried a Bindingtext(objDS,"Contact").EndCurrentEdit and this
didn't work.

What is the bet way to update when I only have one row in the dataset? Any
help would be appreciated.

Thanks,

Gary
Nov 20 '05 #1
6 1076
Cor
Hi Gary,

I see nothing wrong on first sight.

However when you want to update it than you need to do a dataadapter update
after that end current edit you are using. Put before that a commandbuilder.
When this is to few information message again.

And as advice remove that terrible obj before your ds, everything is an
object or a value in VB.net.

Cor
Nov 20 '05 #2
Cor
Hi Gary,

I see nothing wrong on first sight.

However when you want to update it than you need to do a dataadapter update
after that end current edit you are using. Put before that a commandbuilder.
When this is to few information message again.

And as advice remove that terrible obj before your ds, everything is an
object or a value in VB.net.

Cor
Nov 20 '05 #3
Cor,

Could you elaborate on exactly what commands I need? I don't understand. Be
verbose as I am new at VB.NET.

Thanks,

Gary

"Cor" <no*@non.com> wrote in message
news:up**************@TK2MSFTNGP12.phx.gbl...
Hi Gary,

I see nothing wrong on first sight.

However when you want to update it than you need to do a dataadapter update after that end current edit you are using. Put before that a commandbuilder. When this is to few information message again.

And as advice remove that terrible obj before your ds, everything is an
object or a value in VB.net.

Cor

Nov 20 '05 #4
Cor,

Could you elaborate on exactly what commands I need? I don't understand. Be
verbose as I am new at VB.NET.

Thanks,

Gary

"Cor" <no*@non.com> wrote in message
news:up**************@TK2MSFTNGP12.phx.gbl...
Hi Gary,

I see nothing wrong on first sight.

However when you want to update it than you need to do a dataadapter update after that end current edit you are using. Put before that a commandbuilder. When this is to few information message again.

And as advice remove that terrible obj before your ds, everything is an
object or a value in VB.net.

Cor

Nov 20 '05 #5
Hi Gary,

strSQL = "Select * from Contact WHERE sysID = '" & g_sysID & "'"
Dim DA As New SqlClient.SqlDataAdapter(strSQL, CN)
DA.Fill(objDS, "Contact")
Me.txtFirstName.DataBindings.Add("Text", objDS, "Contact.first_name")
Me.txtLastName.DataBindings.Add("Text", objDS, "Contact.Last_name")
Me.txtPhone.DataBindings.Add("Text", objDS, "Contact.Phone1")

In a buttonclickevent (you make that by clicking on a button in the designer
than it apears in the bottom of your code)

I typed all here in confirming your code (wath typos), the error trapping is
very basic and should be in a multiuser environment more complete.

strSQL = "Select * from Contact WHERE sysID = '" & g_sysID & "'"
Dim DA As New SqlClient.SqlDataAdapter(strSQL, CN)
dim cmb as new SqlClient.SqlCommandbuilder(DA)
if objDs.haschanges then
Try
da.update(objDs)
Catch sqlExc As SqlException
MessageBox.Show(sqlExc.ToString)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
end if

I hope this helps?

Cor


Nov 20 '05 #6
Hi Gary,

strSQL = "Select * from Contact WHERE sysID = '" & g_sysID & "'"
Dim DA As New SqlClient.SqlDataAdapter(strSQL, CN)
DA.Fill(objDS, "Contact")
Me.txtFirstName.DataBindings.Add("Text", objDS, "Contact.first_name")
Me.txtLastName.DataBindings.Add("Text", objDS, "Contact.Last_name")
Me.txtPhone.DataBindings.Add("Text", objDS, "Contact.Phone1")

In a buttonclickevent (you make that by clicking on a button in the designer
than it apears in the bottom of your code)

I typed all here in confirming your code (wath typos), the error trapping is
very basic and should be in a multiuser environment more complete.

strSQL = "Select * from Contact WHERE sysID = '" & g_sysID & "'"
Dim DA As New SqlClient.SqlDataAdapter(strSQL, CN)
dim cmb as new SqlClient.SqlCommandbuilder(DA)
if objDs.haschanges then
Try
da.update(objDs)
Catch sqlExc As SqlException
MessageBox.Show(sqlExc.ToString)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
end if

I hope this helps?

Cor


Nov 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Jason | last post by:
Let's say I have an html form with 20 or 30 fields in it. The form submits the fields via POST to a php page which updates a table in a database with the $_POST vars. Which makes more sense? ...
6
by: Hennie de Nooijer | last post by:
Hi, Currently we're a building a metadatadriven datawarehouse in SQL Server 2000. We're investigating the possibility of the updating tables with enormeous number of updates and insert and the...
1
by: Mark | last post by:
I'm having a problem updating recordsin an Access DB table. I can update other tables in this db with no problem, and I can dreate new record in all of the tables (including this one.)> But I can't...
3
by: | last post by:
Hello, I have created an ASP.NET 2.0 application that utilized a Gridview Control to display and update/delete data. The problem I am having is that the gridview control is displaying the data...
10
by: jaYPee | last post by:
does anyone experienced slowness when updating a dataset using AcceptChanges? when calling this code it takes many seconds to update the database SqlDataAdapter1.Update(DsStudentCourse1)...
14
by: el_sid | last post by:
Our developers have experienced a problem with updating Web References in Visual Studio.NET 2003. Normally, when a web service class (.asmx) is created, updating the Web Reference will...
34
by: Jeff | last post by:
For years I have been using VBA extensively for updating data to tables after processing. By this I mean if I had to do some intensive processing that resulted in data in temp tables, I would have...
5
by: Mark R. Dawson | last post by:
Hi all, I may be missing something with how databinding works but I have bound a datasource to a control and everything is great, the control updates to reflect the state of my datasource when I...
4
by: Geoff | last post by:
Hi I'm hoping somebody can help me with the following problem that has occurred to me. Suppose I have two tables in an SQL Server database. Let's call these tables A and B. Assume that A has...
0
by: teammcs | last post by:
Hey all, I'm new around here but do Admin over @ PHPHelp.com... I've been developing a project for my degree which is basically based around an ATM machine. Basically my problem is related to...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.