473,394 Members | 1,761 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,394 software developers and data experts.

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 = "myserverlocation"
objconnection = New SqlConnection(strConnection)
dim strSQL as String = "SELECT * FROM employees"
dim daEditEmp as New SqlDataAdapter(strSQL, objConnection)
dim dsTemp as New Dataset()
daEditEmp.Fill(dsTemp, "editemployee")

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

dim row as DataRow = tbl.Rows.Find(session("empid"))
Row.Item("Emp_Num") = EmpNum.text
Row.Item("Emp_Last") = empLast.text
Row.Item("Emp_First") = empFirst.text
Row.Item("Emp_Title") = empTitle.text
Row.Item("Emp_Dept") = empDept.text
Row.Item("Emp_Site") = empSite.selecteditem.value
Row.Item("Emp_Add") = empAdd.text
Row.Item("Emp_Work") = empWork.text
Row.Item("Emp_Fax") = empFax.text
Row.Item("Emp_Home") = empHome.text
Row.Item("Emp_Email") = empEmail.text
Row.Item("Emp_Mgr") = empMgr.text
Row.Item("Emp_Mgr_Phone") = empMgrnum.text
Row.Item("Emp_Pass") = emppass.text

dim cb as New SqlCommandBuilder(daEditEmp)
objConnection.Open()
daEditEmp.Update(dsTemp, "editemployee")
objconnection.close()
fill_page() 'calls procedure to repopulate fields
--end of code--

I appreciate any and all help. Thanks.

--Ron
Nov 18 '05 #1
2 1625
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*********@hotmail.com> wrote in message
news:e6*************************@posting.google.co m...
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 = "myserverlocation"
objconnection = New SqlConnection(strConnection)
dim strSQL as String = "SELECT * FROM employees"
dim daEditEmp as New SqlDataAdapter(strSQL, objConnection)
dim dsTemp as New Dataset()
daEditEmp.Fill(dsTemp, "editemployee")

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

dim row as DataRow = tbl.Rows.Find(session("empid"))
Row.Item("Emp_Num") = EmpNum.text
Row.Item("Emp_Last") = empLast.text
Row.Item("Emp_First") = empFirst.text
Row.Item("Emp_Title") = empTitle.text
Row.Item("Emp_Dept") = empDept.text
Row.Item("Emp_Site") = empSite.selecteditem.value
Row.Item("Emp_Add") = empAdd.text
Row.Item("Emp_Work") = empWork.text
Row.Item("Emp_Fax") = empFax.text
Row.Item("Emp_Home") = empHome.text
Row.Item("Emp_Email") = empEmail.text
Row.Item("Emp_Mgr") = empMgr.text
Row.Item("Emp_Mgr_Phone") = empMgrnum.text
Row.Item("Emp_Pass") = emppass.text

dim cb as New SqlCommandBuilder(daEditEmp)
objConnection.Open()
daEditEmp.Update(dsTemp, "editemployee")
objconnection.close()
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_darkfalz.com> wrote in message news:<Or**************@TK2MSFTNGP12.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*********@hotmail.com> wrote in message
news:e6*************************@posting.google.co m...
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 = "myserverlocation"
objconnection = New SqlConnection(strConnection)
dim strSQL as String = "SELECT * FROM employees"
dim daEditEmp as New SqlDataAdapter(strSQL, objConnection)
dim dsTemp as New Dataset()
daEditEmp.Fill(dsTemp, "editemployee")

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

dim row as DataRow = tbl.Rows.Find(session("empid"))
Row.Item("Emp_Num") = EmpNum.text
Row.Item("Emp_Last") = empLast.text
Row.Item("Emp_First") = empFirst.text
Row.Item("Emp_Title") = empTitle.text
Row.Item("Emp_Dept") = empDept.text
Row.Item("Emp_Site") = empSite.selecteditem.value
Row.Item("Emp_Add") = empAdd.text
Row.Item("Emp_Work") = empWork.text
Row.Item("Emp_Fax") = empFax.text
Row.Item("Emp_Home") = empHome.text
Row.Item("Emp_Email") = empEmail.text
Row.Item("Emp_Mgr") = empMgr.text
Row.Item("Emp_Mgr_Phone") = empMgrnum.text
Row.Item("Emp_Pass") = emppass.text

dim cb as New SqlCommandBuilder(daEditEmp)
objConnection.Open()
daEditEmp.Update(dsTemp, "editemployee")
objconnection.close()
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
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...
7
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...
17
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...
14
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...
16
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...
8
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: ...
5
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...
7
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...
16
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...
0
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
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,...
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.