PC Review


Reply
Thread Tools Rate Thread

Cannot Update Records because of expression DataColumn

 
 
Hemang Shah
Guest
Posts: n/a
 
      30th Jan 2005
I have an expression DataColumn which combines "First Name" + "Last Name" to
display in the list box to select the name, who's record comes up.


But when I use the daDataAdapter.Update(dsDataSet, tblTableName); It gives
me an exception saying cannot update readonly expression type.

How do I fix this?!

Isn't Visual Studio a lot more powerful than access ? So far, I've found
serious limitation in the the controls of Visual Studio.. Like listbox &
ComboBox not being able to have multiple fields!...

There are 3rd party solutions but they all are very expensive..

Please let me know if there are any suggestion for my mentioned problem.

Thank You

HS


 
Reply With Quote
 
 
 
 
Miha Markic [MVP C#]
Guest
Posts: n/a
 
      30th Jan 2005
Hi Hemang,

How is your daDataAdapter configured?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
SLODUG - Slovene Developer Users Group
www.rthand.com

"Hemang Shah" <(E-Mail Removed)> wrote in message
news:fbCdnZYf382HBmHcRVn-(E-Mail Removed)...
>I have an expression DataColumn which combines "First Name" + "Last Name"
>to display in the list box to select the name, who's record comes up.
>
>
> But when I use the daDataAdapter.Update(dsDataSet, tblTableName); It
> gives me an exception saying cannot update readonly expression type.
>
> How do I fix this?!
>
> Isn't Visual Studio a lot more powerful than access ? So far, I've found
> serious limitation in the the controls of Visual Studio.. Like listbox &
> ComboBox not being able to have multiple fields!...
>
> There are 3rd party solutions but they all are very expensive..
>
> Please let me know if there are any suggestion for my mentioned problem.
>
> Thank You
>
> HS
>



 
Reply With Quote
 
Sahil Malik
Guest
Posts: n/a
 
      30th Jan 2005
Hemang,

For such situations, you have to resolve a bit away from point and click and
write code yourself.
Try specifying the Update statement for your data adapter by hand ..


- Sahil Malik
http://codebetter.com/blogs/sahil.malik/





"Hemang Shah" <(E-Mail Removed)> wrote in message
news:fbCdnZYf382HBmHcRVn-(E-Mail Removed)...
>I have an expression DataColumn which combines "First Name" + "Last Name"
>to display in the list box to select the name, who's record comes up.
>
>
> But when I use the daDataAdapter.Update(dsDataSet, tblTableName); It
> gives me an exception saying cannot update readonly expression type.
>
> How do I fix this?!
>
> Isn't Visual Studio a lot more powerful than access ? So far, I've found
> serious limitation in the the controls of Visual Studio.. Like listbox &
> ComboBox not being able to have multiple fields!...
>
> There are 3rd party solutions but they all are very expensive..
>
> Please let me know if there are any suggestion for my mentioned problem.
>
> Thank You
>
> HS
>



 
Reply With Quote
 
Hemang Shah
Guest
Posts: n/a
 
      31st Jan 2005
Hello Miha

My DataAdapter called daClient is like this:

//

// daClient

//

this.daClient.DeleteCommand = this.sqlDeleteCommand2;

this.daClient.InsertCommand = this.sqlInsertCommand2;

this.daClient.SelectCommand = this.sqlSelectCommand2;

this.daClient.TableMappings.AddRange(new
System.Data.Common.DataTableMapping[] {

new System.Data.Common.DataTableMapping("Table", "tblClient", new
System.Data.Common.DataColumnMapping[] {

new System.Data.Common.DataColumnMapping("ClientID", "ClientID"),

new System.Data.Common.DataColumnMapping("LastName", "LastName"),

new System.Data.Common.DataColumnMapping("GivenName", "GivenName"),

new System.Data.Common.DataColumnMapping("Status", "Status"),

new System.Data.Common.DataColumnMapping("ReasonToCloseID",
"ReasonToCloseID"),

new System.Data.Common.DataColumnMapping("DOB", "DOB"),

new System.Data.Common.DataColumnMapping("Gender", "Gender"),

new System.Data.Common.DataColumnMapping("MaritalStat", "MaritalStat"),

new System.Data.Common.DataColumnMapping("ImmigStat", "ImmigStat"),

new System.Data.Common.DataColumnMapping("SIN", "SIN"),

new System.Data.Common.DataColumnMapping("HealthCard", "HealthCard"),

new System.Data.Common.DataColumnMapping("WorkPermit", "WorkPermit"),

new System.Data.Common.DataColumnMapping("Origin", "Origin"),

new System.Data.Common.DataColumnMapping("CameToCanada", "CameToCanada"),

new System.Data.Common.DataColumnMapping("FirstLang", "FirstLang"),

new System.Data.Common.DataColumnMapping("OtherLang", "OtherLang"),

new System.Data.Common.DataColumnMapping("ChildMinding", "ChildMinding"),

new System.Data.Common.DataColumnMapping("Education", "Education"),

new System.Data.Common.DataColumnMapping("Discipline", "Discipline"),

new System.Data.Common.DataColumnMapping("PrevOcc", "PrevOcc"),

new System.Data.Common.DataColumnMapping("PresOcc", "PresOcc"),

new System.Data.Common.DataColumnMapping("TargetOcc", "TargetOcc"),

new System.Data.Common.DataColumnMapping("WorkingNow", "WorkingNow"),

new System.Data.Common.DataColumnMapping("WorkingSince", "WorkingSince"),

new System.Data.Common.DataColumnMapping("WorkCDN", "WorkCDN"),

new System.Data.Common.DataColumnMapping("SourceIncome", "SourceIncome"),

new System.Data.Common.DataColumnMapping("Referal", "Referal"),

new System.Data.Common.DataColumnMapping("SocialWrk", "SocialWrk"),

new System.Data.Common.DataColumnMapping("ResumeLoc", "ResumeLoc"),

new System.Data.Common.DataColumnMapping("ResumeType", "ResumeType"),

new System.Data.Common.DataColumnMapping("PhoneType", "PhoneType"),

new System.Data.Common.DataColumnMapping("PhoneNum", "PhoneNum"),

new System.Data.Common.DataColumnMapping("AltPhoneType", "AltPhoneType"),

new System.Data.Common.DataColumnMapping("AltPhoneNum", "AltPhoneNum"),

new System.Data.Common.DataColumnMapping("Email", "Email"),

new System.Data.Common.DataColumnMapping("SingleMother", "SingleMother"),

new System.Data.Common.DataColumnMapping("LongTermGoal", "LongTermGoal"),

new System.Data.Common.DataColumnMapping("LongTermGoalComments",
"LongTermGoalComments"),

new System.Data.Common.DataColumnMapping("ShortTermGoal", "ShortTermGoal"),

new System.Data.Common.DataColumnMapping("ShortTermGoalComments",
"ShortTermGoalComments"),

new System.Data.Common.DataColumnMapping("NextStepComments",
"NextStepComments")})});

this.daClient.UpdateCommand = this.sqlUpdateCommand2;



My Expression DataColumn is defined as below in the form_load procedure:



private void frmClient_Load(object sender, System.EventArgs e)

{

DataColumn dcFullName = new DataColumn();

this.daClient.Fill(this.dsClient);

this.daChild.Fill(this.dsClient);

this.daClientAddress.Fill(this.dsClient);

dcFullName.DataType = System.Type.GetType("System.String");

dcFullName.ColumnName = "FullNameFN";

dcFullName.Expression = "GivenName + ' ' + LastName";

this.dsClient.tblClient.Columns.Add(dcFullName);

this.dvClient.Sort = "GivenName";

lstName.DataSource = dvClient;

lstName.DisplayMember = "dcFullName";

lstName.ValueMember = "ClientID";

lstName.SelectedIndex = 1;

}



I checked my autogenerated Update method, and it doesn't add the FullNameFN
in it either.

It acts funny, because the first time I click update, it works fine, the
second time, it throws an exception.



Any suggestion?



"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:(E-Mail Removed)...
> Hi Hemang,
>
> How is your daDataAdapter configured?
>
> --
> Miha Markic [MVP C#] - RightHand .NET consulting & development
> SLODUG - Slovene Developer Users Group
> www.rthand.com
>
> "Hemang Shah" <(E-Mail Removed)> wrote in message
> news:fbCdnZYf382HBmHcRVn-(E-Mail Removed)...
>>I have an expression DataColumn which combines "First Name" + "Last Name"
>>to display in the list box to select the name, who's record comes up.
>>
>>
>> But when I use the daDataAdapter.Update(dsDataSet, tblTableName); It
>> gives me an exception saying cannot update readonly expression type.
>>
>> How do I fix this?!
>>
>> Isn't Visual Studio a lot more powerful than access ? So far, I've found
>> serious limitation in the the controls of Visual Studio.. Like listbox &
>> ComboBox not being able to have multiple fields!...
>>
>> There are 3rd party solutions but they all are very expensive..
>>
>> Please let me know if there are any suggestion for my mentioned problem.
>>
>> Thank You
>>
>> HS
>>

>
>



 
Reply With Quote
 
Hemang Shah
Guest
Posts: n/a
 
      31st Jan 2005
Hello Sahil

The update method doesn't include that expression column, I already checked
that.

Thanks

"Sahil Malik" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hemang,
>
> For such situations, you have to resolve a bit away from point and click
> and write code yourself.
> Try specifying the Update statement for your data adapter by hand ..
>
>
> - Sahil Malik
> http://codebetter.com/blogs/sahil.malik/
>
>
>
>
>
> "Hemang Shah" <(E-Mail Removed)> wrote in message
> news:fbCdnZYf382HBmHcRVn-(E-Mail Removed)...
>>I have an expression DataColumn which combines "First Name" + "Last Name"
>>to display in the list box to select the name, who's record comes up.
>>
>>
>> But when I use the daDataAdapter.Update(dsDataSet, tblTableName); It
>> gives me an exception saying cannot update readonly expression type.
>>
>> How do I fix this?!
>>
>> Isn't Visual Studio a lot more powerful than access ? So far, I've found
>> serious limitation in the the controls of Visual Studio.. Like listbox &
>> ComboBox not being able to have multiple fields!...
>>
>> There are 3rd party solutions but they all are very expensive..
>>
>> Please let me know if there are any suggestion for my mentioned problem.
>>
>> Thank You
>>
>> HS
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataColumn.Expression Andrzej Kaczmarczyk Microsoft ADO .NET 3 17th Oct 2005 03:22 PM
DataColumn.Expression Ray Microsoft ADO .NET 1 17th Nov 2004 10:17 AM
DataColumn Expression Joel Rumerman Microsoft Dot NET Framework Forms 10 11th Aug 2004 09:03 AM
DataColumn Expression Sébastien Microsoft ADO .NET 1 2nd Feb 2004 03:45 PM
DataColumn.Expression Rodrigo Microsoft ADO .NET 1 7th Oct 2003 07:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:54 PM.