Hi, I apologize for a newbie question, but my books/research have yielded me
no examples and my time is now short.
I simply want to update data from text boxes (fields). I'm not using a
datagrid or datalist I found plenty of examples of how to do that and can get
that to work. I simply want to update my databound text boxes.
I'm using visual studios DataAdapters, DataSets and Dataviews. I can insert
to the database utilizing the sqladapter, but I can't figure out how to
update or delete using the records unique id / primary key.
Can someone please direct me to an example or show me sample code.
Preferrably in vb. I'm desperate. :)
Thanks,
enrique 4 1342
So in your button click event you're going to have to write the SQL to do
an update back to your database:
Dim cn as new SqlConnection() ' this assumes you're using SqlServer
cn.ConnectionString = "some connection string (depends upon your DB and security
settings)"
cn.Open()
Dim cmd as SqlCOmmand = cn.CreateCommand()
cmd.CommandText = "update YourTable set x=@x, y=@y where z=@z"
cmd.Parameters.Add("@x", txtBoxX.Text)
cmd.Parameters.Add("@y", txtBoxY.Text)
cmd.Parameters.Add("@z", txtBoxZ.Text)
cmd.ExecuteNonQuery()
cmd.Dispose() ' technically we need to call Dispose(), as SqlCommand implements
IDisposable
cn.Close() ' Don't forget to close the connection
-Brock
DevelopMentor http://staff.develop.com/ballen Hi, I apologize for a newbie question, but my books/research have yielded me no examples and my time is now short.
I simply want to update data from text boxes (fields). I'm not using a datagrid or datalist I found plenty of examples of how to do that and can get that to work. I simply want to update my databound text boxes. I'm using visual studios DataAdapters, DataSets and Dataviews. I can insert to the database utilizing the sqladapter, but I can't figure out how to update or delete using the records unique id / primary key. Can someone please direct me to an example or show me sample code. Preferrably in vb. I'm desperate. :)
Thanks, enrique
Brock, Thank you very much.
Although I was looking for a solution that manipulates the disconnected data
and then updates via the sqlDataAdapter, this did the trick and I'm very
grateful.
I'll figure out updating dataTables and dataRows another day. (but if you
have the answer you can shoot it my way :) )
Again, Thanks!
-enrique
"Brock Allen" wrote: So in your button click event you're going to have to write the SQL to do an update back to your database:
Dim cn as new SqlConnection() ' this assumes you're using SqlServer cn.ConnectionString = "some connection string (depends upon your DB and security settings)" cn.Open() Dim cmd as SqlCOmmand = cn.CreateCommand() cmd.CommandText = "update YourTable set x=@x, y=@y where z=@z" cmd.Parameters.Add("@x", txtBoxX.Text) cmd.Parameters.Add("@y", txtBoxY.Text) cmd.Parameters.Add("@z", txtBoxZ.Text) cmd.ExecuteNonQuery() cmd.Dispose() ' technically we need to call Dispose(), as SqlCommand implements IDisposable cn.Close() ' Don't forget to close the connection
-Brock DevelopMentor http://staff.develop.com/ballen Hi, I apologize for a newbie question, but my books/research have yielded me no examples and my time is now short.
I simply want to update data from text boxes (fields). I'm not using a datagrid or datalist I found plenty of examples of how to do that and can get that to work. I simply want to update my databound text boxes. I'm using visual studios DataAdapters, DataSets and Dataviews. I can insert to the database utilizing the sqladapter, but I can't figure out how to update or delete using the records unique id / primary key. Can someone please direct me to an example or show me sample code. Preferrably in vb. I'm desperate. :)
Thanks, enrique
How is what I suggested not disconnected data? SqlDataAdpater is just a layer
on SqlConnection and SqlCommand.
-Brock
DevelopMentor http://staff.develop.com/ballen Brock, Thank you very much. Although I was looking for a solution that manipulates the disconnected data and then updates via the sqlDataAdapter, this did the trick and I'm very grateful. I'll figure out updating dataTables and dataRows another day. (but if you have the answer you can shoot it my way :) ) Again, Thanks! -enrique "Brock Allen" wrote:
So in your button click event you're going to have to write the SQL to do an update back to your database:
Dim cn as new SqlConnection() ' this assumes you're using SqlServer cn.ConnectionString = "some connection string (depends upon your DB and security settings)" cn.Open() Dim cmd as SqlCOmmand = cn.CreateCommand() cmd.CommandText = "update YourTable set x=@x, y=@y where z=@z" cmd.Parameters.Add("@x", txtBoxX.Text) cmd.Parameters.Add("@y", txtBoxY.Text) cmd.Parameters.Add("@z", txtBoxZ.Text) cmd.ExecuteNonQuery() cmd.Dispose() ' technically we need to call Dispose(), as SqlCommand implements IDisposable cn.Close() ' Don't forget to close the connection -Brock DevelopMentor http://staff.develop.com/ballen Hi, I apologize for a newbie question, but my books/research have yielded me no examples and my time is now short.
I simply want to update data from text boxes (fields). I'm not using a datagrid or datalist I found plenty of examples of how to do that and can get that to work. I simply want to update my databound text boxes. I'm using visual studios DataAdapters, DataSets and Dataviews. I can insert to the database utilizing the sqladapter, but I can't figure out how to update or delete using the records unique id / primary key. Can someone please direct me to an example or show me sample code. Preferrably in vb. I'm desperate. :) Thanks, enrique This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: vanisathish |
last post by:
Hi,
Currently we are updating the html page contents, some text boxes using
javascript. Is it possible to update the same from am activeX dll.
And in javascript, will there be any impact on...
|
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: stosh259 |
last post by:
Hi everyone,
Anyone have a generic procedure to updating different types of controls
on a form. I have text boxes and switches (booleans). I would like to
loop through all the controls and...
|
by: kolalakitty |
last post by:
Hopefully someone here can help me/point me in the right direction.
I've found tons of references towards making relations, creating rows,
saving said rows, using datagrids, databinding objects,...
|
by: Dave |
last post by:
I want to put the information that the user selects in my combo boxes
into a subform that lies on the same form as the combo boxes.
Thanks for your help already,
Dave
|
by: chimambo |
last post by:
Hi All,
I have a little problem. I am retrieving records from a table and I
want to update the records using checkboxes. I am able to display the
database record quite alright and I have created...
|
by: Marianne160 |
last post by:
Hi,
I know there are various answers to this problem available on the web but none of them seem to work for me. I am using Access 2003 to make a form to look up data from a table. I have so far...
|
by: adalyc |
last post by:
I NEED SOME GUIDENCE WITH UPDATING A COLLECTION OF ITEMS IN A LIST BOX WHEN THE USER CLICKS ON A BUTTON FROM ANOTHER FORM,, i HAVE LISTED THE PROBLEM PARTIALLY. I fIGURED OUT MOST OF THE PROBLEM...
|
by: Code Monkey |
last post by:
Suppose I have a windows form (.exe) that has a load of labels and
text boxes on it.
I enter a number into one of the text boxes and hit the search button.
This then launches another thread,...
|
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...
|
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: 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: 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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |