TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
thenndral
NA
45
30.8k
Update DataTable - Error
Oct 4 2011 10:29 PM
Hi,
I'm using C#2008
DB - Oracle11G
I have a problem while update data using Datatable.
Herewith i Attach my code. please check where I did mistake.
private void btnSave_Click(object sender, EventArgs e)
{
connectionString = "User Id=tom;Password=pwd4tom;Data Source=remote_oracle";
cn = new OracleConnection(connectionString);
OracleCommand command;
string insertQuery = @"insert into employee(id, name, dept, address, active) Values
(@id, @name, @dept, @address, @active)";
command = new OracleCommand(insertQuery, cn);
command.Parameters.Add("@id", OracleDbType.Int16, 5, "id");
command.Parameters.Add("@name", OracleDbType.Varchar2, 50, "name");
command.Parameters.Add("@dept", OracleDbType.Varchar2, 3, "dept");
command.Parameters.Add("@address", OracleDbType.Varchar2, 50, "address");
command.Parameters.Add("@active", OracleDbType.Varchar2, 1, "active");
adapter.InsertCommand = command;
string updateQuery = @"update employee set name=@name, dept=@dept, address=@address,
active=@active where id=@id";
command = new OracleCommand(updateQuery, cn);
command.Parameters.Add("@name", OracleDbType.Varchar2, 50, "name");
command.Parameters.Add("@dept", OracleDbType.Varchar2, 3, "dept");
command.Parameters.Add("@address", OracleDbType.Varchar2, 50, "address");
command.Parameters.Add("@active", OracleDbType.Varchar2, 10, "active");
OracleParameter param1 = command.Parameters.Add("@id", OracleDbType.Int16, 5, "id");
param1.SourceVersion = DataRowVersion.Original;
adapter.UpdateCommand = command;
string deleteQuery = @"Delete employee where id=@id";
command = new OracleCommand(deleteQuery, cn);
OracleParameter paramd1 = command.Parameters.Add("@id", OracleDbType.Int16, 5, "id");
paramd1.SourceVersion = DataRowVersion.Original;
adapter.DeleteCommand = command;
adapter.Update(empTbl); // What goes wrong here....
}
thanks,
thenndral.
Attachment:
datagrid_samples.zip
Reply
Answers (
7
)
Re-adding a List
Course outline for WPF and WCF and Silverlight