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 842
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: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |