Dataset update problem

  • Thread starter Thread starter Elliot
  • Start date Start date
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.
 
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
 
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.
 
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.
 
Back
Top