I want to update an employee's name, here's my code:
public void Save(int aEmployeeID, string aFirstame, string aLastname)
{
SqlDataAdapter DaEmployee;
DataSet DsEmployee;
// _Conn is instantiated in constructor
DaEmployee = new SqlDataAdapter("UPDATE employee " +
"SET
firstname = " + aFirstname + ", lastname = " + aLastname +
" WHERE
employeeID = " + aEmployeeID.ToString(), _Conn);
DsEmployee = new DataSet();
DaEmployee.Fill(DsEmployee, "employee");
.........................................
} 2 1167
Alan,
This will never get you to "First base". The DataAdapter "Fill" method is
only for populating a DataSet with the results of a SELECT query. You want to
use the DataAdapter's "Update" method, and supply a valid Update Command,
along with any other SqlCommands that are necessary.
Peter
--
Co-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
"Alan" wrote: I want to update an employee's name, here's my code: public void Save(int aEmployeeID, string aFirstame, string aLastname)
{
SqlDataAdapter DaEmployee;
DataSet DsEmployee;
// _Conn is instantiated in constructor
DaEmployee = new SqlDataAdapter("UPDATE employee " +
"SET firstname = " + aFirstname + ", lastname = " + aLastname +
" WHERE employeeID = " + aEmployeeID.ToString(), _Conn);
DsEmployee = new DataSet();
DaEmployee.Fill(DsEmployee, "employee");
.........................................
}
Could you give me few lines of code in my case what should I do please ?
"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:3B**********************************@microsof t.com... Alan, This will never get you to "First base". The DataAdapter "Fill" method is only for populating a DataSet with the results of a SELECT query. You want to use the DataAdapter's "Update" method, and supply a valid Update Command, along with any other SqlCommands that are necessary. Peter
-- Co-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com UnBlog: http://petesbloggerama.blogspot.com
"Alan" wrote:
I want to update an employee's name, here's my code: public void Save(int aEmployeeID, string aFirstame, string aLastname)
{
SqlDataAdapter DaEmployee;
DataSet DsEmployee;
// _Conn is instantiated in constructor
DaEmployee = new SqlDataAdapter("UPDATE employee " +
"SET firstname = " + aFirstname + ", lastname = " + aLastname +
" WHERE employeeID = " + aEmployeeID.ToString(), _Conn);
DsEmployee = new DataSet();
DaEmployee.Fill(DsEmployee, "employee");
.........................................
} This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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:
...
|
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...
|
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...
|
by: sirdavethebrave |
last post by:
Hi guys -
I have written a form, and a stored procedure to update the said form.
It really is as simple as that. A user can go into the form, update some fields and hit the update button 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:
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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: 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...
| |