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/
>