MSDOTnet.org Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Dataset update problem

 
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> ASPNet
Author Message
Elliot



Joined: 12 Dec 2007
Posts: 5

PostPosted: Thu Dec 13, 2007 5:45 am    Post subject: Dataset update problem Reply with quote

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.

Archived from group: microsoft>public>dotnet>framework>aspnet
Back to top
View user's profile Send private message
Peter Bromberg [C# MVP]



Joined: 31 Oct 2007
Posts: 22

PostPosted: Wed Dec 12, 2007 3:12 pm    Post subject: RE: Dataset update problem Reply with quote

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" wrote:

> 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 to top
View user's profile Send private message
Elliot



Joined: 12 Dec 2007
Posts: 5

PostPosted: Thu Dec 13, 2007 6:36 pm    Post subject: Re: Dataset update problem Reply with quote

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 [C# MVP]" wrote in message @microsoft.com...
> 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" wrote:
>
>> 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 to top
View user's profile Send private message
Elliot



Joined: 12 Dec 2007
Posts: 5

PostPosted: Fri Dec 14, 2007 12:08 am    Post subject: Re: Dataset update problem Reply with quote

solved



"Peter Bromberg [C# MVP]" wrote in message @microsoft.com...
> 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" wrote:
>
>> 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 to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
dataset refreshing after update hello i bind dbf file to dataset, single update call after inserting on updating rows on dataset works just fine but second update throwing exception with 'wrong field COUNT' , thanks for any help ....

DataAdapter.Update problem I have a DataAdapter that connects to this table. Table1 Field1 unique int Identity Field2 int Field3 int I did this, which fails for (...) { Field3); } 'TableName); // An exception about unique cons

TableAdapter Update problem Hi There I'm using the TableAdapter method to save changes to my record. Some fields are filled in but those don't update to the database at all. Why is this? Code sample follows: = Format(Now, Us

New column update problem....! I made a procedure Public Sub Novo(ByVal nova1 As String, ByVal nova2 As String) that creates a new with insert update select and delete commads. I also added that commands can change depending how many columns are in a Table. I add a new

Windows Update Problem Security Update for Microsoft .NET Framework, Version 2.0 (KB928365) Security Update for Microsoft .NET Framework, Version 1.1 Service Pack 1 (KB928366) I am not able to install the above 2 updates for my Windows XP SP2
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> ASPNet All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group