Dataset update problem

E

Elliot

OracleConnection conn = new OracleConnection(ConnectionString);
OracleCommand cmdProfile = new OracleCommand("select * from Profile where
profile id = '1'", conn);
OracleDataAdapter adpProfile = new OracleDataAdapter();
adpProfile.SelectCommand = cmdProfile;
DataSet dsProfile = new DataSet();
adpProfile.Fill(dsProfile, "ProfileTable");
DataRow selectedRow = dsProfile.Tables["ProfileTable"].Rows[0];
selectedRow["FName"] = Profile_FName.Text;
adpProfile.Update(dsProfile, "ProfileTable");

When executing the above statement, no error return, but nothing changed in
database. What's going on?

Any idea would be appreciated.
 
P

Peter Bromberg [C# MVP]

I see a couple of potential problems with your SQL Statement

select * from Profile where profile id = '1'" :

1) profile id is two words. It should probably be profileid (1 word)
2) = '1' is a string. Most likely the profileId column is integer, so you
need to remove the single quotes.
3) You should really be using a parameterized query.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
 
E

Elliot

Thanks for your idea, Peter.
"profile id" is just a retyping mistake. In fact, it is "profileid" in both
the code and the database. And, its datatype is varchar(Because I added some
characters before it sometimes).
What is parameterized query?



Peter Bromberg said:
I see a couple of potential problems with your SQL Statement

select * from Profile where profile id = '1'" :

1) profile id is two words. It should probably be profileid (1 word)
2) = '1' is a string. Most likely the profileId column is integer, so you
need to remove the single quotes.
3) You should really be using a parameterized query.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com


Elliot said:
OracleConnection conn = new OracleConnection(ConnectionString);
OracleCommand cmdProfile = new OracleCommand("select * from Profile where
profile id = '1'", conn);
OracleDataAdapter adpProfile = new OracleDataAdapter();
adpProfile.SelectCommand = cmdProfile;
DataSet dsProfile = new DataSet();
adpProfile.Fill(dsProfile, "ProfileTable");
DataRow selectedRow = dsProfile.Tables["ProfileTable"].Rows[0];
selectedRow["FName"] = Profile_FName.Text;
adpProfile.Update(dsProfile, "ProfileTable");

When executing the above statement, no error return, but nothing changed
in
database. What's going on?

Any idea would be appreciated.
 
E

Elliot

solved



Peter Bromberg said:
I see a couple of potential problems with your SQL Statement

select * from Profile where profile id = '1'" :

1) profile id is two words. It should probably be profileid (1 word)
2) = '1' is a string. Most likely the profileId column is integer, so you
need to remove the single quotes.
3) You should really be using a parameterized query.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com


Elliot said:
OracleConnection conn = new OracleConnection(ConnectionString);
OracleCommand cmdProfile = new OracleCommand("select * from Profile where
profile id = '1'", conn);
OracleDataAdapter adpProfile = new OracleDataAdapter();
adpProfile.SelectCommand = cmdProfile;
DataSet dsProfile = new DataSet();
adpProfile.Fill(dsProfile, "ProfileTable");
DataRow selectedRow = dsProfile.Tables["ProfileTable"].Rows[0];
selectedRow["FName"] = Profile_FName.Text;
adpProfile.Update(dsProfile, "ProfileTable");

When executing the above statement, no error return, but nothing changed
in
database. What's going on?

Any idea would be appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,165
Latest member
JavierBrak
Top