473,656 Members | 2,793 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Issues with Stongly-Typed ObjectDataSourc e's UpdateMethod

I really hope this is not a case of "this silly thing will never
work".....lots of time invested in troubleshooting this already.

I have created a standard ASP.NET web form (.aspx) with several collections
of textboxes prompting for entry into a fairly monolithic database. I
decided to create a business object (called Employee) and use the
ObjectDataSourc e to broker data being transmitted between the UI and my
Employee object (and subsequently the database). This works just great for
reading data into all the fields. But for some reason, and despite from all
appearnaces I'm doing exactly what all the examples suggest one should do,
the Update method (Update()) refuses to update edits made to any of the bound
textboxes. I really need help with this - or very bad things might happen to
me.

Here's the declaration for the ObjectDataSourc e control on the page:

1 <asp:ObjectData Source ID="odsEmployee Edit" runat="server"
SelectMethod="G etEntity"
2 TypeName="GC.Fi nance.Web500.Da ta.EmployeeAdap ter"
DataObjectTypeN ame="GC.Finance .Web500.Data.PS Employee"
3 DeleteMethod="D elete" InsertMethod="I nsert"
UpdateMethod="U pdate">
4 <SelectParamete rs>
5 <asp:QueryStrin gParameter Name="id" QueryStringFiel d="empl"
Type="Int32" />
6 </SelectParameter s Notice above that the DataObjectTypeN ame
is set to the PSEmployee object, thus making this a storngly-typed
ObjectDataSourc e. (This is the business ojbect described as the "Employee"
object above.) I did fine one example where a strongly-typed
ObjectDataSourc e was used at
http://msdn2.microsoft.com/en-gb/library/ms227562.aspx.

And just to give you an idea how all the textboxes are bound on the page to
this datasource, I'll include a partial listing from the .aspx file in
question:

1 <asp:FormView ID="frmvwEmploy eeMain" DataSourceID="o dsEmployeeEdit"
runat="server">
2
3 <ItemTemplate >
4 <table id="tblMainInfo ">
5 <tr>
6 <td class="TabArea" valign="top" style="text-align:
left">
7 <uc2:EmployeeOr g ID="EmployeeOrg 1"
runat="server" />
8 <table>
9 <tr>
10 <td>
11 <table>
12 <tr>
13 <td style="width: 114px">
14 <asp:Label
ID="lblTitleEn " runat="server" meta:resourceke y="lblTitleEnRe source1"
Text="Title (English):"></asp:Label></td>
15 <td colspan="3">
16 <asp:TextBox
ID="txtTitleEn " runat="server" meta:resourceke y="txtTitleEnRe source1"
Text='<%# Bind("TitleEngl ish") %>'></asp:TextBox></td>
17 </tr>
18 <tr>
19 <td style="height: 26px;
width: 114px;">
20 <asp:Label
ID="lblTitleFr " runat="server" meta:resourceke y="lblTitleFrRe source1"
Text="Title (French):"></asp:Label></td>
21 <td colspan="3">
22 <asp:TextBox
ID="txtTitleFr " runat="server" meta:resourceke y="txtTitleFrRe source1"
Text='<%# Bind("TitleFren ch") %>'></asp:TextBox></td>
23 </trSo as you can see form
the above, <%# Bind() %statements referencing the FormView's datasource are
useful for displaying data. But when the Update() method gets called, the
PSEmployee's New() method is invovked, creating an "empty" instance. And,
consequently, when the EmployeeAdapter 's Update() method is invoked, the
PSEmployee instance passed therein has no values - nothing is passed in from
the web form:

1 Public Class EmployeeAdapter
2 Inherits DirectoryServic esAdapter
3 Implements IDisposable
4
5 Public Sub New()
6
7 MyBase.New()
8
9 End Sub
10
11 ...
12
13 Public Overrides Function Update(ByVal de As IDirectoryEntit y) As
Boolean
14
15 Dim retVal As Boolean = de.Update()
16 Return retVal
17
18 End Function
19
20 Public Overloads Function Update(ByVal empl As PSEmployee) As Boolean
21
22 Return Update(CType(em pl, IDirectoryEntit y))
23
24 End Function
25
26 ...
27
28 (and so on...) In other words, on line 22 in the listing above, the
empl instance of PSEmployee has empty values, meaning nothing was passed from
the web form.

The error that ultimately results when this code is executed, thus, is simply:

Server Error in '/Update500' Application.
--------------------------------------------------------------------------------

Procedure 'sp_EmployeeUpd ate' expects parameter '@surname', which was not
supplied.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.Data.Sql Client.SqlExcep tion: Procedure
'sp_EmployeeUpd ate' expects parameter '@surname', which was not supplied.

Source Error:

Line 31: Protected Sub btnUpdate_Click (ByVal sender As Object, ByVal e
As System.EventArg s) Handles btnUpdate.Click
Line 32:
Line 33: _dso.Update()
Line 34:
Line 35: End Sub

Source File: c:\inetpub\wwwr oot\Update500\U serControls\Emp loyeeCRUD.ascx. vb
Line: 33

Stack Trace:

[SqlException (0x80131904): Procedure 'sp_EmployeeUpd ate' expects parameter
'@surname', which was not supplied.]
System.Data.Sql Client.SqlConne ction.OnError(S qlException exception,
Boolean breakConnection ) +857338
System.Data.Sql Client.SqlInter nalConnection.O nError(SqlExcep tion
exception, Boolean breakConnection ) +734950

System.Data.Sql Client.TdsParse r.ThrowExceptio nAndWarning(Tds ParserStateObje ct
stateObj) +188
System.Data.Sql Client.TdsParse r.Run(RunBehavi or runBehavior, SqlCommand
cmdHandler, SqlDataReader dataStream, BulkCopySimpleR esultSet
bulkCopyHandler , TdsParserStateO bject stateObj) +1838
System.Data.Sql Client.SqlComma nd.FinishExecut eReader(SqlData Reader ds,
RunBehavior runBehavior, String resetOptionsStr ing) +149
System.Data.Sql Client.SqlComma nd.RunExecuteRe aderTds(Command Behavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
+886
System.Data.Sql Client.SqlComma nd.RunExecuteRe ader(CommandBeh avior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method,
DbAsyncResult result) +132
System.Data.Sql Client.SqlComma nd.InternalExec uteNonQuery(DbA syncResult
result, String methodName, Boolean sendToPipe) +415
System.Data.Sql Client.SqlComma nd.ExecuteNonQu ery() +135
GC.Finance.Web5 00.Data.PSEmplo yee.Update() in C:\Documents and
Settings\rholde r\My Documents\Visua l Studio
2005\Projects\G C.Finance.X500. Data\GC.Finance .X500.Data\Enti ties\PSEmployee .vb:211
GC.Finance.Web5 00.Data.Employe eAdapter.Update (IDirectoryEnti ty de) in
C:\Documents and Settings\rholde r\My Documents\Visua l Studio
2005\Projects\G C.Finance.X500. Data\GC.Finance .X500.Data\Adap ters\EmployeeAd apter.vb:80
GC.Finance.Web5 00.Data.Employe eAdapter.Update (PSEmployee empl) in
C:\Documents and Settings\rholde r\My Documents\Visua l Studio
2005\Projects\G C.Finance.X500. Data\GC.Finance .X500.Data\Adap ters\EmployeeAd apter.vb:87

NOTE: I have also tried adding a DataKeyNames property ("ID", the index
property for the Employee business object) to the FormView control; which has
had no impact on this issue.

Really need help with this one - thanks for any and all assistance!

Appreciatively,

--------------------------------------------------------------------------------
Ross Holder,
Ottawa, ON (Canada)
http://ross613.spaces.msn.com
"The more you know, the more you wanna know more."
Mar 6 '07 #1
1 1690
Hi Ross,

I just went through this same process for the 1st time using GridView &
DetailsView with no problems - I have not tried the FormView.

What does your PSEmployee class look like - specifically property
declarations & Update method ?
Why are you handling the Button.Click event & what is the _dso that it is
referring to , should it actually be odsEmployeeEdit ?

1st check - PSEmployee bindable values are defined as public properties and
not fields.
2nd check - verify that PSEmployee.Upda te is building the update command
properly

Gerry
"ross613" <ro*****@discus sions.microsoft .comwrote in message
news:FF******** *************** ***********@mic rosoft.com...
>I really hope this is not a case of "this silly thing will never
work".....lots of time invested in troubleshooting this already.

I have created a standard ASP.NET web form (.aspx) with several
collections
of textboxes prompting for entry into a fairly monolithic database. I
decided to create a business object (called Employee) and use the
ObjectDataSourc e to broker data being transmitted between the UI and my
Employee object (and subsequently the database). This works just great
for
reading data into all the fields. But for some reason, and despite from
all
appearnaces I'm doing exactly what all the examples suggest one should do,
the Update method (Update()) refuses to update edits made to any of the
bound
textboxes. I really need help with this - or very bad things might happen
to
me.

Here's the declaration for the ObjectDataSourc e control on the page:

1 <asp:ObjectData Source ID="odsEmployee Edit" runat="server"
SelectMethod="G etEntity"
2 TypeName="GC.Fi nance.Web500.Da ta.EmployeeAdap ter"
DataObjectTypeN ame="GC.Finance .Web500.Data.PS Employee"
3 DeleteMethod="D elete" InsertMethod="I nsert"
UpdateMethod="U pdate">
4 <SelectParamete rs>
5 <asp:QueryStrin gParameter Name="id"
QueryStringFiel d="empl"
Type="Int32" />
6 </SelectParameter s Notice above that the DataObjectTypeN ame
is set to the PSEmployee object, thus making this a storngly-typed
ObjectDataSourc e. (This is the business ojbect described as the
"Employee"
object above.) I did fine one example where a strongly-typed
ObjectDataSourc e was used at
http://msdn2.microsoft.com/en-gb/library/ms227562.aspx.

And just to give you an idea how all the textboxes are bound on the page
to
this datasource, I'll include a partial listing from the .aspx file in
question:

1 <asp:FormView ID="frmvwEmploy eeMain" DataSourceID="o dsEmployeeEdit"
runat="server">
2
3 <ItemTemplate >
4 <table id="tblMainInfo ">
5 <tr>
6 <td class="TabArea" valign="top"
style="text-align:
left">
7 <uc2:EmployeeOr g ID="EmployeeOrg 1"
runat="server" />
8 <table>
9 <tr>
10 <td>
11 <table>
12 <tr>
13 <td style="width: 114px">
14 <asp:Label
ID="lblTitleEn " runat="server" meta:resourceke y="lblTitleEnRe source1"
Text="Title (English):"></asp:Label></td>
15 <td colspan="3">
16 <asp:TextBox
ID="txtTitleEn " runat="server" meta:resourceke y="txtTitleEnRe source1"
Text='<%# Bind("TitleEngl ish") %>'></asp:TextBox></td>
17 </tr>
18 <tr>
19 <td style="height: 26px;
width: 114px;">
20 <asp:Label
ID="lblTitleFr " runat="server" meta:resourceke y="lblTitleFrRe source1"
Text="Title (French):"></asp:Label></td>
21 <td colspan="3">
22 <asp:TextBox
ID="txtTitleFr " runat="server" meta:resourceke y="txtTitleFrRe source1"
Text='<%# Bind("TitleFren ch") %>'></asp:TextBox></td>
23 </trSo as you can see form
the above, <%# Bind() %statements referencing the FormView's datasource
are
useful for displaying data. But when the Update() method gets called, the
PSEmployee's New() method is invovked, creating an "empty" instance. And,
consequently, when the EmployeeAdapter 's Update() method is invoked, the
PSEmployee instance passed therein has no values - nothing is passed in
from
the web form:

1 Public Class EmployeeAdapter
2 Inherits DirectoryServic esAdapter
3 Implements IDisposable
4
5 Public Sub New()
6
7 MyBase.New()
8
9 End Sub
10
11 ...
12
13 Public Overrides Function Update(ByVal de As IDirectoryEntit y) As
Boolean
14
15 Dim retVal As Boolean = de.Update()
16 Return retVal
17
18 End Function
19
20 Public Overloads Function Update(ByVal empl As PSEmployee) As
Boolean
21
22 Return Update(CType(em pl, IDirectoryEntit y))
23
24 End Function
25
26 ...
27
28 (and so on...) In other words, on line 22 in the listing above, the
empl instance of PSEmployee has empty values, meaning nothing was passed
from
the web form.

The error that ultimately results when this code is executed, thus, is
simply:

Server Error in '/Update500' Application.
--------------------------------------------------------------------------------

Procedure 'sp_EmployeeUpd ate' expects parameter '@surname', which was not
supplied.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about
the error and where it originated in the code.

Exception Details: System.Data.Sql Client.SqlExcep tion: Procedure
'sp_EmployeeUpd ate' expects parameter '@surname', which was not supplied.

Source Error:

Line 31: Protected Sub btnUpdate_Click (ByVal sender As Object, ByVal e
As System.EventArg s) Handles btnUpdate.Click
Line 32:
Line 33: _dso.Update()
Line 34:
Line 35: End Sub

Source File:
c:\inetpub\wwwr oot\Update500\U serControls\Emp loyeeCRUD.ascx. vb
Line: 33

Stack Trace:

[SqlException (0x80131904): Procedure 'sp_EmployeeUpd ate' expects
parameter
'@surname', which was not supplied.]
System.Data.Sql Client.SqlConne ction.OnError(S qlException exception,
Boolean breakConnection ) +857338
System.Data.Sql Client.SqlInter nalConnection.O nError(SqlExcep tion
exception, Boolean breakConnection ) +734950

System.Data.Sql Client.TdsParse r.ThrowExceptio nAndWarning(Tds ParserStateObje ct
stateObj) +188
System.Data.Sql Client.TdsParse r.Run(RunBehavi or runBehavior, SqlCommand
cmdHandler, SqlDataReader dataStream, BulkCopySimpleR esultSet
bulkCopyHandler , TdsParserStateO bject stateObj) +1838
System.Data.Sql Client.SqlComma nd.FinishExecut eReader(SqlData Reader ds,
RunBehavior runBehavior, String resetOptionsStr ing) +149
System.Data.Sql Client.SqlComma nd.RunExecuteRe aderTds(Command Behavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
+886
System.Data.Sql Client.SqlComma nd.RunExecuteRe ader(CommandBeh avior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method,
DbAsyncResult result) +132
System.Data.Sql Client.SqlComma nd.InternalExec uteNonQuery(DbA syncResult
result, String methodName, Boolean sendToPipe) +415
System.Data.Sql Client.SqlComma nd.ExecuteNonQu ery() +135
GC.Finance.Web5 00.Data.PSEmplo yee.Update() in C:\Documents and
Settings\rholde r\My Documents\Visua l Studio
2005\Projects\G C.Finance.X500. Data\GC.Finance .X500.Data\Enti ties\PSEmployee .vb:211
GC.Finance.Web5 00.Data.Employe eAdapter.Update (IDirectoryEnti ty de) in
C:\Documents and Settings\rholde r\My Documents\Visua l Studio
2005\Projects\G C.Finance.X500. Data\GC.Finance .X500.Data\Adap ters\EmployeeAd apter.vb:80
GC.Finance.Web5 00.Data.Employe eAdapter.Update (PSEmployee empl) in
C:\Documents and Settings\rholde r\My Documents\Visua l Studio
2005\Projects\G C.Finance.X500. Data\GC.Finance .X500.Data\Adap ters\EmployeeAd apter.vb:87

NOTE: I have also tried adding a DataKeyNames property ("ID", the index
property for the Employee business object) to the FormView control; which
has
had no impact on this issue.

Really need help with this one - thanks for any and all assistance!

Appreciatively,

--------------------------------------------------------------------------------
Ross Holder,
Ottawa, ON (Canada)
http://ross613.spaces.msn.com
"The more you know, the more you wanna know more."

Mar 7 '07 #2

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

Similar topics

2
2075
by: Tom Loredo | last post by:
Hi folks- I'm about to move from a Solaris 8/SPARC environment to a Dell running RedHat 9. Are there any issues I need to be aware of in bringing my Python code over (mostly scientific computation)? In particular, I know earlier versions of RH shipped with an "old" Python installed as "python" and that installation of more recent versions should not overwrite "python" (e.g., install as "python2.3"). Is this still the case in RH9? Any...
28
2786
by: grahamd | last post by:
Who are the appropriate people to report security problems to in respect of a module included with the Python distribution? I don't feel it appropriate to be reporting it on general mailing lists.
5
4677
by: sandy | last post by:
Hi All, I am a newbie to MySQL and Python. At the first place, I would like to know what are the general performance issues (if any) of using MySQL with Python. By performance, I wanted to know how will the speed be, what is the memory overhead involved, etc during database specific operations (retrieval, update, insert, etc) when MySQL is used with Python.
1
1667
by: Aliandro | last post by:
Hi Does any one know where I can find information regarding any issues with SQL and IIS being run under windows XP SP2? as I am in the process of programmning in Dot net and neet some way of knowing if there are any issues before I start. So if some one can please inform me of a place that has this information that would be greatly appreciated. Thanks Ali
7
1846
by: David Laub | last post by:
I have stumbled across various Netscape issues, none of which appear to be solvable by tweaking the clientTarget or targetSchema properties. At this point, I'm not even interested in "solving" these problems - I'm more interested in isolating them, .i.e. finding a "complete" list of issues. Here's my list of serious issues found so far. By serious, I mean functionality that fails, as opposed to much less serious (albeit annoying) display...
2
3037
by: G2 | last post by:
Hi We are dealing with significant browser compatibility issues with Netscape 5.x+ browsers and Mac IE. I am sure most web developers have faced similar issues in the past. Can anyone give me their thoughts on how they were able to address these issues ? Are there any best practices published by MS on how to ensure browser compatibility when coding asp.net Thanks for any input.
10
3076
by: Robert | last post by:
I have an app that was originally 1.1, now migrated to 2.0 and have run into some sporadic viewstate errors...usually saying the viewstate is invalid, eventvalidation failed or mac error. My web config does specify a machinekey setting: <machineKey validationKey="447C05E8B3A71401CC4CAE5513A7F1A3494A3618EE819316AAD1D58433F236A759D66FB4154500E01EB4E1BC1DE42046E2D652D391CB8367A1649438867A02EB"...
1
1962
by: GaryDean | last post by:
We have been developing all of our .net applications on 32 bit windows using 32 bit SQL Server. We are being asked to now deploy to servers running 64bit windows and 64bit SQL Server. Are there issues? Differences? Should we switch our dev environment to 64bit. What is the advantage of going with 64 bit servers other than being able to address more memory? Thanks, Gary
3
1652
by: eschneider | last post by:
Just some common issues with WS: Using custom objects: When objects change, seems you are always fixing some issue. Update references, which sometimes does not work. Deployment: Weird errors which take a while to fix because the error stink: Forget to set ASP.NET 2.0="Parser Error Message: Could not load type" '*.Global' is ambiguous: it could come from assembly=I deleted the
0
8382
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8297
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8717
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8498
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7311
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5629
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
1930
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.