473,396 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Q: Displaying computed database fields, gives error on saving...

Hi!

I have two computed datafields that i am displaying in my windowsform.

When i try to update the dataset and commit the transaction.

I get an error message telling me that i cant update calculated fields. That
i can understand
but how to tell the dataset or what ever to NOT do this update to the
server?

Regards
Martin
Oct 27 '06 #1
9 1443
Hi Martin,

Yeah, that sucks. Remove the expression before doing update and reapply it
after.
Perhaps there is a better solution out there..

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"Martin Arvidsson" <ye*******@ms.comwrote in message
news:%2******************@TK2MSFTNGP03.phx.gbl...
Hi!

I have two computed datafields that i am displaying in my windowsform.

When i try to update the dataset and commit the transaction.

I get an error message telling me that i cant update calculated fields.
That i can understand
but how to tell the dataset or what ever to NOT do this update to the
server?

Regards
Martin

Oct 29 '06 #2
Sorry for a perhaps stupid follow up question.

What expression should i remove before update :)

Regards
Martin

"Miha Markic [MVP C#]" <miha at rthand comskrev i meddelandet
news:%2*******************@TK2MSFTNGP02.phx.gbl...
Hi Martin,

Yeah, that sucks. Remove the expression before doing update and reapply it
after.
Perhaps there is a better solution out there..

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"Martin Arvidsson" <ye*******@ms.comwrote in message
news:%2******************@TK2MSFTNGP03.phx.gbl...
>Hi!

I have two computed datafields that i am displaying in my windowsform.

When i try to update the dataset and commit the transaction.

I get an error message telling me that i cant update calculated fields.
That i can understand
but how to tell the dataset or what ever to NOT do this update to the
server?

Regards
Martin


Oct 30 '06 #3

"Martin Arvidsson" <ye*******@ms.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Sorry for a perhaps stupid follow up question.

What expression should i remove before update :)
DataColumn.Expression = null;

Or even better, remove entire column :-)

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
Oct 31 '06 #4
Ok, but here is the tricky part.

The column is computed in the table level at the sql server.

So i guess i have to exclude the fields and build a view that shows the
fields where thay can't be modifyed.

I was so stupid to believe that C# could be integrated smoothly with fields
like this ;)

Regards
Martin
"Miha Markic [MVP C#]" <miha at rthand comskrev i meddelandet
news:ux**************@TK2MSFTNGP03.phx.gbl...
>
"Martin Arvidsson" <ye*******@ms.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>Sorry for a perhaps stupid follow up question.

What expression should i remove before update :)

DataColumn.Expression = null;

Or even better, remove entire column :-)

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Oct 31 '06 #5
Hi Martin,

Aha, I was under impression that you use DataColumn.Expression.
Now, what does your adapter's code look like?

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
"Martin Arvidsson" <ye*******@ms.comwrote in message
news:u9**************@TK2MSFTNGP05.phx.gbl...
Ok, but here is the tricky part.

The column is computed in the table level at the sql server.

So i guess i have to exclude the fields and build a view that shows the
fields where thay can't be modifyed.

I was so stupid to believe that C# could be integrated smoothly with
fields like this ;)

Regards
Martin
"Miha Markic [MVP C#]" <miha at rthand comskrev i meddelandet
news:ux**************@TK2MSFTNGP03.phx.gbl...
>>
"Martin Arvidsson" <ye*******@ms.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>>Sorry for a perhaps stupid follow up question.

What expression should i remove before update :)

DataColumn.Expression = null;

Or even better, remove entire column :-)

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/


Nov 1 '06 #6
What code snipp do you want me to send to you?

There is a lot of code ;)

Regards
Martin
"Miha Markic [MVP C#]" <miha at rthand comskrev i meddelandet
news:eC*************@TK2MSFTNGP02.phx.gbl...
Hi Martin,

Aha, I was under impression that you use DataColumn.Expression.
Now, what does your adapter's code look like?

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
"Martin Arvidsson" <ye*******@ms.comwrote in message
news:u9**************@TK2MSFTNGP05.phx.gbl...
>Ok, but here is the tricky part.

The column is computed in the table level at the sql server.

So i guess i have to exclude the fields and build a view that shows the
fields where thay can't be modifyed.

I was so stupid to believe that C# could be integrated smoothly with
fields like this ;)

Regards
Martin
"Miha Markic [MVP C#]" <miha at rthand comskrev i meddelandet
news:ux**************@TK2MSFTNGP03.phx.gbl...
>>>
"Martin Arvidsson" <ye*******@ms.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl.. .
Sorry for a perhaps stupid follow up question.

What expression should i remove before update :)

DataColumn.Expression = null;

Or even better, remove entire column :-)

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/



Nov 2 '06 #7
What code snipp do you want me to send to you?

There is a lot of code ;)

Regards
Martin
"Miha Markic [MVP C#]" <miha at rthand comskrev i meddelandet
news:eC*************@TK2MSFTNGP02.phx.gbl...
Hi Martin,

Aha, I was under impression that you use DataColumn.Expression.
Now, what does your adapter's code look like?

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
"Martin Arvidsson" <ye*******@ms.comwrote in message
news:u9**************@TK2MSFTNGP05.phx.gbl...
>Ok, but here is the tricky part.

The column is computed in the table level at the sql server.

So i guess i have to exclude the fields and build a view that shows the
fields where thay can't be modifyed.

I was so stupid to believe that C# could be integrated smoothly with
fields like this ;)

Regards
Martin
"Miha Markic [MVP C#]" <miha at rthand comskrev i meddelandet
news:ux**************@TK2MSFTNGP03.phx.gbl...
>>>
"Martin Arvidsson" <ye*******@ms.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl.. .
Sorry for a perhaps stupid follow up question.

What expression should i remove before update :)

DataColumn.Expression = null;

Or even better, remove entire column :-)

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/




Nov 2 '06 #8
Just the adapter's insert and update commands..

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"Martin Arvidsson" <ye*******@ms.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
What code snipp do you want me to send to you?

There is a lot of code ;)

Regards
Martin
"Miha Markic [MVP C#]" <miha at rthand comskrev i meddelandet
news:eC*************@TK2MSFTNGP02.phx.gbl...
>Hi Martin,

Aha, I was under impression that you use DataColumn.Expression.
Now, what does your adapter's code look like?

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
"Martin Arvidsson" <ye*******@ms.comwrote in message
news:u9**************@TK2MSFTNGP05.phx.gbl...
>>Ok, but here is the tricky part.

The column is computed in the table level at the sql server.

So i guess i have to exclude the fields and build a view that shows the
fields where thay can't be modifyed.

I was so stupid to believe that C# could be integrated smoothly with
fields like this ;)

Regards
Martin
"Miha Markic [MVP C#]" <miha at rthand comskrev i meddelandet
news:ux**************@TK2MSFTNGP03.phx.gbl...

"Martin Arvidsson" <ye*******@ms.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl. ..
Sorry for a perhaps stupid follow up question.
>
What expression should i remove before update :)

DataColumn.Expression = null;

Or even better, remove entire column :-)

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/




Nov 2 '06 #9
Hi Miha!

Here comes the code finaly...

The fieldname is TotalWorkHour

/Regards
Martin
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.ComponentModel.Design.HelpKeywordAttribute( "vs.data.TableAdapter")]
[System.ComponentModel.DataObjectMethodAttribute(Sy stem.ComponentModel.DataObjectMethodType.Insert,
true)]
public virtual int Insert(int ProjectSub, int ProjectMain, string
Description, System.Nullable<boolProjectLocked, System.Nullable<int>
TotalWorkTime, int CustomerNo, int ContactID, string DescriptionOfProject,
System.Nullable<intTotalWorkHour) {
this.Adapter.InsertCommand.Parameters[0].Value = ((int)(ProjectSub));
this.Adapter.InsertCommand.Parameters[1].Value = ((int)(ProjectMain));
if ((Description == null)) {
throw new System.ArgumentNullException("Description");
}
else {
this.Adapter.InsertCommand.Parameters[2].Value = ((string)(Description));
}
if ((ProjectLocked.HasValue == true)) {
this.Adapter.InsertCommand.Parameters[3].Value =
((bool)(ProjectLocked.Value));
}
else {
this.Adapter.InsertCommand.Parameters[3].Value = System.DBNull.Value;
}
if ((TotalWorkTime.HasValue == true)) {
this.Adapter.InsertCommand.Parameters[4].Value =
((int)(TotalWorkTime.Value));
}
else {
this.Adapter.InsertCommand.Parameters[4].Value = System.DBNull.Value;
}
this.Adapter.InsertCommand.Parameters[5].Value = ((int)(CustomerNo));
this.Adapter.InsertCommand.Parameters[6].Value = ((int)(ContactID));
if ((DescriptionOfProject == null)) {
this.Adapter.InsertCommand.Parameters[7].Value = System.DBNull.Value;
}
else {
this.Adapter.InsertCommand.Parameters[7].Value =
((string)(DescriptionOfProject));
}
if ((TotalWorkHour.HasValue == true)) {
this.Adapter.InsertCommand.Parameters[8].Value =
((int)(TotalWorkHour.Value));
}
else {
this.Adapter.InsertCommand.Parameters[8].Value = System.DBNull.Value;
}
System.Data.ConnectionState previousConnectionState =
this.Adapter.InsertCommand.Connection.State;
if (((this.Adapter.InsertCommand.Connection.State &
System.Data.ConnectionState.Open)
!= System.Data.ConnectionState.Open)) {
this.Adapter.InsertCommand.Connection.Open();
}
try {
int returnValue = this.Adapter.InsertCommand.ExecuteNonQuery();
return returnValue;
}
finally {
if ((previousConnectionState == System.Data.ConnectionState.Closed)) {
this.Adapter.InsertCommand.Connection.Close();
}
}
}
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.ComponentModel.Design.HelpKeywordAttribute( "vs.data.TableAdapter")]
[System.ComponentModel.DataObjectMethodAttribute(Sy stem.ComponentModel.DataObjectMethodType.Update,
true)]
public virtual int Update(
int ProjectSub,
int ProjectMain,
string Description,
System.Nullable<boolProjectLocked,
System.Nullable<intTotalWorkTime,
int CustomerNo,
int ContactID,
string DescriptionOfProject,
System.Nullable<intTotalWorkHour,
int Original_ProjectID,
int Original_ProjectSub,
int Original_ProjectMain,
string Original_Description,
System.Nullable<boolOriginal_ProjectLocked,
System.Nullable<intOriginal_TotalWorkTime,
int Original_CustomerNo,
int Original_ContactID,
System.Nullable<intOriginal_TotalWorkHour,
int ProjectID) {
this.Adapter.UpdateCommand.Parameters[0].Value = ((int)(ProjectSub));
this.Adapter.UpdateCommand.Parameters[1].Value = ((int)(ProjectMain));
if ((Description == null)) {
throw new System.ArgumentNullException("Description");
}
else {
this.Adapter.UpdateCommand.Parameters[2].Value = ((string)(Description));
}
if ((ProjectLocked.HasValue == true)) {
this.Adapter.UpdateCommand.Parameters[3].Value =
((bool)(ProjectLocked.Value));
}
else {
this.Adapter.UpdateCommand.Parameters[3].Value = System.DBNull.Value;
}
if ((TotalWorkTime.HasValue == true)) {
this.Adapter.UpdateCommand.Parameters[4].Value =
((int)(TotalWorkTime.Value));
}
else {
this.Adapter.UpdateCommand.Parameters[4].Value = System.DBNull.Value;
}
this.Adapter.UpdateCommand.Parameters[5].Value = ((int)(CustomerNo));
this.Adapter.UpdateCommand.Parameters[6].Value = ((int)(ContactID));
if ((DescriptionOfProject == null)) {
this.Adapter.UpdateCommand.Parameters[7].Value = System.DBNull.Value;
}
else {
this.Adapter.UpdateCommand.Parameters[7].Value =
((string)(DescriptionOfProject));
}
if ((TotalWorkHour.HasValue == true)) {
this.Adapter.UpdateCommand.Parameters[8].Value =
((int)(TotalWorkHour.Value));
}
else {
this.Adapter.UpdateCommand.Parameters[8].Value = System.DBNull.Value;
}
this.Adapter.UpdateCommand.Parameters[9].Value =
((int)(Original_ProjectID));
this.Adapter.UpdateCommand.Parameters[10].Value =
((int)(Original_ProjectSub));
this.Adapter.UpdateCommand.Parameters[11].Value =
((int)(Original_ProjectMain));
if ((Original_Description == null)) {
throw new System.ArgumentNullException("Original_Description ");
}
else {
this.Adapter.UpdateCommand.Parameters[12].Value =
((string)(Original_Description));
}
if ((Original_ProjectLocked.HasValue == true)) {
this.Adapter.UpdateCommand.Parameters[13].Value = ((object)(0));
this.Adapter.UpdateCommand.Parameters[14].Value =
((bool)(Original_ProjectLocked.Value));
}
else {
this.Adapter.UpdateCommand.Parameters[13].Value = ((object)(1));
this.Adapter.UpdateCommand.Parameters[14].Value = System.DBNull.Value;
}
if ((Original_TotalWorkTime.HasValue == true)) {
this.Adapter.UpdateCommand.Parameters[15].Value = ((object)(0));
this.Adapter.UpdateCommand.Parameters[16].Value =
((int)(Original_TotalWorkTime.Value));
}
else {
this.Adapter.UpdateCommand.Parameters[15].Value = ((object)(1));
this.Adapter.UpdateCommand.Parameters[16].Value = System.DBNull.Value;
}
this.Adapter.UpdateCommand.Parameters[17].Value =
((int)(Original_CustomerNo));
this.Adapter.UpdateCommand.Parameters[18].Value =
((int)(Original_ContactID));
if ((Original_TotalWorkHour.HasValue == true)) {
this.Adapter.UpdateCommand.Parameters[19].Value = ((object)(0));
this.Adapter.UpdateCommand.Parameters[20].Value =
((int)(Original_TotalWorkHour.Value));
}
else {
this.Adapter.UpdateCommand.Parameters[19].Value = ((object)(1));
this.Adapter.UpdateCommand.Parameters[20].Value = System.DBNull.Value;
}
this.Adapter.UpdateCommand.Parameters[21].Value = ((int)(ProjectID));
System.Data.ConnectionState previousConnectionState =
this.Adapter.UpdateCommand.Connection.State;
if (((this.Adapter.UpdateCommand.Connection.State &
System.Data.ConnectionState.Open)
!= System.Data.ConnectionState.Open)) {
this.Adapter.UpdateCommand.Connection.Open();
}
try {
int returnValue = this.Adapter.UpdateCommand.ExecuteNonQuery();
return returnValue;
}
finally {
if ((previousConnectionState == System.Data.ConnectionState.Closed)) {
this.Adapter.UpdateCommand.Connection.Close();
}
}
}


"Miha Markic [MVP C#]" <miha at rthand comskrev i meddelandet
news:Ou**************@TK2MSFTNGP04.phx.gbl...
Just the adapter's insert and update commands..

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"Martin Arvidsson" <ye*******@ms.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>What code snipp do you want me to send to you?

There is a lot of code ;)

Regards
Martin
"Miha Markic [MVP C#]" <miha at rthand comskrev i meddelandet
news:eC*************@TK2MSFTNGP02.phx.gbl...
>>Hi Martin,

Aha, I was under impression that you use DataColumn.Expression.
Now, what does your adapter's code look like?

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
"Martin Arvidsson" <ye*******@ms.comwrote in message
news:u9**************@TK2MSFTNGP05.phx.gbl...
Ok, but here is the tricky part.

The column is computed in the table level at the sql server.

So i guess i have to exclude the fields and build a view that shows the
fields where thay can't be modifyed.

I was so stupid to believe that C# could be integrated smoothly with
fields like this ;)

Regards
Martin
"Miha Markic [MVP C#]" <miha at rthand comskrev i meddelandet
news:ux**************@TK2MSFTNGP03.phx.gbl...
>
"Martin Arvidsson" <ye*******@ms.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl.. .
>Sorry for a perhaps stupid follow up question.
>>
>What expression should i remove before update :)
>
DataColumn.Expression = null;
>
Or even better, remove entire column :-)
>
--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>





Nov 13 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: euang | last post by:
Hi, I have been using access 2000 for two years on WINDOWS NT to display dynamic aweb page using ASP My ISP has now changed to Windows 2003, and I am having major problems displaying...
1
by: Paulo Andre Ortega Ribeiro | last post by:
I have a table with fields called fname (First Name) and lname (Last Name). I need the user´s email thai is compose from lname and fname: LOWER(LEFT (fname,1) + lname) Is there any difference...
0
by: Pato Secruza | last post by:
Hi everyone! I have a really frustrating error and need help. I’m trying to do a function that gets the properties and names of the fields in a MS Access database using ASP. I haven’t...
6
by: Matt K. | last post by:
Hi there, I have a form in an Access project that contains a subform which displays the results of a query of the style "select * from where = #a certain date#". In the main part of the form...
6
by: stephan.vanbeerschoten | last post by:
Hi All, I am relatively new to MS Access but am wel suited in general relational databases. I seem to be unable to accomplish the displaying of query results that return more then one line item....
5
by: MLH | last post by:
I use a fair number of debug.print statements. My apps are fairly well 'peppered' with them. I've often wondered if leaving them in the mdb, creating and rolling out an mde intended for use in the...
3
by: josh.kuo | last post by:
Sorry about the subject, I can't think of a better one. I recently wrote some PHP classes that I think might be of interest to this group. Since I have been reaping the benefits of reading news...
4
by: Drew | last post by:
I posted this to the asp.db group, but it doesn't look like there is much activity on there, also I noticed that there are a bunch of posts on here pertaining to database and asp. Sorry for...
7
by: Aamir Mahmood | last post by:
Hi All I have DataTable object. Is there a way that I can know which fields (columns) in the table are computed. Apparantly the DataTable.Columns returns all columns both computed and other....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.