473,786 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Update table help

Ron
Hello,

I am trying to do a simple update on employee information. I am a
novice at both aspx and SQLServer, so I hope you are not too offended
by my code. The following is the update code:

--Start of code--
dim objConnection as SqlConnection
dim daAddEmp as SqlDataAdapter
dim strconnection as string = "myserverlocati on"
objconnection = New SqlConnection(s trConnection)
dim strSQL as String = "SELECT * FROM employees"
dim daEditEmp as New SqlDataAdapter( strSQL, objConnection)
dim dsTemp as New Dataset()
daEditEmp.Fill( dsTemp, "editemploy ee")

dim tbl as DataTable = dsTemp.Tables(" editemployee")
tbl.PrimaryKey = New DataColumn() _
{ tbl.Columns("em p_id") }

dim row as DataRow = tbl.Rows.Find(s ession("empid") )
Row.Item("Emp_N um") = EmpNum.text
Row.Item("Emp_L ast") = empLast.text
Row.Item("Emp_F irst") = empFirst.text
Row.Item("Emp_T itle") = empTitle.text
Row.Item("Emp_D ept") = empDept.text
Row.Item("Emp_S ite") = empSite.selecte ditem.value
Row.Item("Emp_A dd") = empAdd.text
Row.Item("Emp_W ork") = empWork.text
Row.Item("Emp_F ax") = empFax.text
Row.Item("Emp_H ome") = empHome.text
Row.Item("Emp_E mail") = empEmail.text
Row.Item("Emp_M gr") = empMgr.text
Row.Item("Emp_M gr_Phone") = empMgrnum.text
Row.Item("Emp_P ass") = emppass.text

dim cb as New SqlCommandBuild er(daEditEmp)
objConnection.O pen()
daEditEmp.Updat e(dsTemp, "editemploy ee")
objconnection.c lose()
fill_page() 'calls procedure to repopulate fields
--end of code--

I appreciate any and all help. Thanks.

--Ron
Nov 18 '05 #1
2 1644
I'd suggest an "update table...." as opposed to a "select " and then
..Update.
You will find life will be MUCH easier.

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Ron" <ju*********@ho tmail.com> wrote in message
news:e6******** *************** **@posting.goog le.com...
Hello,

I am trying to do a simple update on employee information. I am a
novice at both aspx and SQLServer, so I hope you are not too offended
by my code. The following is the update code:

--Start of code--
dim objConnection as SqlConnection
dim daAddEmp as SqlDataAdapter
dim strconnection as string = "myserverlocati on"
objconnection = New SqlConnection(s trConnection)
dim strSQL as String = "SELECT * FROM employees"
dim daEditEmp as New SqlDataAdapter( strSQL, objConnection)
dim dsTemp as New Dataset()
daEditEmp.Fill( dsTemp, "editemploy ee")

dim tbl as DataTable = dsTemp.Tables(" editemployee")
tbl.PrimaryKey = New DataColumn() _
{ tbl.Columns("em p_id") }

dim row as DataRow = tbl.Rows.Find(s ession("empid") )
Row.Item("Emp_N um") = EmpNum.text
Row.Item("Emp_L ast") = empLast.text
Row.Item("Emp_F irst") = empFirst.text
Row.Item("Emp_T itle") = empTitle.text
Row.Item("Emp_D ept") = empDept.text
Row.Item("Emp_S ite") = empSite.selecte ditem.value
Row.Item("Emp_A dd") = empAdd.text
Row.Item("Emp_W ork") = empWork.text
Row.Item("Emp_F ax") = empFax.text
Row.Item("Emp_H ome") = empHome.text
Row.Item("Emp_E mail") = empEmail.text
Row.Item("Emp_M gr") = empMgr.text
Row.Item("Emp_M gr_Phone") = empMgrnum.text
Row.Item("Emp_P ass") = emppass.text

dim cb as New SqlCommandBuild er(daEditEmp)
objConnection.O pen()
daEditEmp.Updat e(dsTemp, "editemploy ee")
objconnection.c lose()
fill_page() 'calls procedure to repopulate fields
--end of code--

I appreciate any and all help. Thanks.

--Ron

Nov 18 '05 #2
Ron
Hey Curt,

Thanks for the response. Your suggestion is noted. As it turns out,
after I implemented your suggestion the update still would not work. I
finally find the mistake though. The same 'fill_page()' procedure I
call at the end of the update procedure is called in the page_load
procedure... w/o a postback if/then!! So I was replacing the updated
data w/ the existing data and therefore 'updating' w/ the unchanged
info. Oh well, novice mistake. Hopefully somebody else will learn
from this post. Thanks again.
"Curt_C [MVP]" <software_AT_da rkfalz.com> wrote in message news:<Or******* *******@TK2MSFT NGP12.phx.gbl>. ..
I'd suggest an "update table...." as opposed to a "select " and then
.Update.
You will find life will be MUCH easier.

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Ron" <ju*********@ho tmail.com> wrote in message
news:e6******** *************** **@posting.goog le.com...
Hello,

I am trying to do a simple update on employee information. I am a
novice at both aspx and SQLServer, so I hope you are not too offended
by my code. The following is the update code:

--Start of code--
dim objConnection as SqlConnection
dim daAddEmp as SqlDataAdapter
dim strconnection as string = "myserverlocati on"
objconnection = New SqlConnection(s trConnection)
dim strSQL as String = "SELECT * FROM employees"
dim daEditEmp as New SqlDataAdapter( strSQL, objConnection)
dim dsTemp as New Dataset()
daEditEmp.Fill( dsTemp, "editemploy ee")

dim tbl as DataTable = dsTemp.Tables(" editemployee")
tbl.PrimaryKey = New DataColumn() _
{ tbl.Columns("em p_id") }

dim row as DataRow = tbl.Rows.Find(s ession("empid") )
Row.Item("Emp_N um") = EmpNum.text
Row.Item("Emp_L ast") = empLast.text
Row.Item("Emp_F irst") = empFirst.text
Row.Item("Emp_T itle") = empTitle.text
Row.Item("Emp_D ept") = empDept.text
Row.Item("Emp_S ite") = empSite.selecte ditem.value
Row.Item("Emp_A dd") = empAdd.text
Row.Item("Emp_W ork") = empWork.text
Row.Item("Emp_F ax") = empFax.text
Row.Item("Emp_H ome") = empHome.text
Row.Item("Emp_E mail") = empEmail.text
Row.Item("Emp_M gr") = empMgr.text
Row.Item("Emp_M gr_Phone") = empMgrnum.text
Row.Item("Emp_P ass") = emppass.text

dim cb as New SqlCommandBuild er(daEditEmp)
objConnection.O pen()
daEditEmp.Updat e(dsTemp, "editemploy ee")
objconnection.c lose()
fill_page() 'calls procedure to repopulate fields
--end of code--

I appreciate any and all help. Thanks.

--Ron

Nov 18 '05 #3

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

Similar topics

3
3272
by: laurie | last post by:
Hi all, I'm trying to help out a friend who has inherited a client with a PHP shopping cart application. Neither of us know PHP, but I've been muddling my way through, trying to get these old scripts working on a new server with the most recent version of PHP. I've pretty much taken care of all the various errors that were popping up. Most only pointed out out non-fatal undefined or assumed variables. I've been able to cure most of...
7
248484
by: Dave | last post by:
I have 2 tables, one with names, and another with addresses, joined by their CIVICID number (unique to the ADDRESSINFO table) in Oracle. I need to update a field in the NAMEINFO table for a particular surname in a particular town. I can select the records fine with this syntax (testing in Oracle SQL* Plus) SELECT NAMEINFO.LASTNAME, NAMEINFO.FIRSTNAME, NAMEINFO.MIDDLENAME, NAMEINFO.GENDER, ADDRESSINFO.REGION FROM NAMEINFO, ADDRESSINFO...
17
5029
by: kalamos | last post by:
This statement fails update ded_temp a set a.balance = (select sum(b.ln_amt) from ded_temp b where a.cust_no = b.cust_no and a.ded_type_cd = b.ded_type_cd and a.chk_no = b.chk_no group by cust_no, ded_type_cd, chk_no)
14
4301
by: serge | last post by:
I have a scenario where two tables are in a One-to-Many relationship and I need to move the data from the Many table to the One table so that it becomes a One-to-One relationship. I need to salvage the records from the many table and without going into detail, one of the reasons I can't do the opposite as there are records in the ONE table that I need to keep even if they don't have any child records in the MANY table. Below I created...
16
17020
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums must be UPDATED, if not, they must be INSERTED. Logically then, I would like to SELECT * FROM <TABLE> WHERE ....<Values entered here>, and then IF FOUND UPDATE <TABLE> SET .... <Values entered here> ELSE INSERT INTO <TABLE> VALUES <Values...
8
3725
by: Maxi | last post by:
There is a lotto system which picks 21 numbers every day out of 80 numbers. I have a table (name:Lotto) with 22 fields (name:Date,P1,P2....P21) Here is the structure and sample data: "Date","P1","P2","P3","P4","P5","P6","P7","P8","P9","P10","P11","P12","P13","P14","P15","P16","P17","P18","P19","P20","P21" 1/1/2005,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21 1/2/2005,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22
5
3543
by: PAUL | last post by:
Hello, I have 2 tables with a relationship set up in the dataset with vb ..net. I add a new record to the parent table then edit an existing child record to have the new parent ID. However when I do the update the changed parentid in the child table fails to change. No error is given its just that the change is not written to the Database. When I step through the records for the child table the one I would expect to be changed has a row...
7
9782
by: Jon Maz | last post by:
Hi, I have a MySql problem I hope someone can help me with. I'm trying to run an update on a linking table, the update is running into a Primary Key constraint violation, and in my workaround I've got stuck trying to write a DELETE statement. Here's the table I'm working on: CREATE TABLE `articles_categories` (
16
3501
by: Ian Davies | last post by:
Hello Needing help with a suitable solution. I have extracted records into a table under three columns 'category', 'comment' and share (the category column also holds the index no of the record in a hidden field) I wish the user to be able to edit the data in the table, so I have extracted the records into hiddenfield, textareas, dropdown list and checkbox so that they can make changes. I named these elements as arrays and wish to run an...
0
2535
KalariaNitya
by: KalariaNitya | last post by:
Hello, could anybody help me? i have gridview, inside gridview i have one Update button & textbox update button update the quantity entered in textbox. i want to update the quantity on textbox on ENTER event. i had done below code: page_load()
0
9647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9492
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10360
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10163
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10108
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8988
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4064
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.