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 6 1077
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
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
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
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
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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?
...
|
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...
|
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...
|
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...
|
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)...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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...
| |