473,403 Members | 2,293 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,403 software developers and data experts.

Issues with Stongly-Typed ObjectDataSource'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
ObjectDataSource 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 ObjectDataSource control on the page:

1 <asp:ObjectDataSource ID="odsEmployeeEdit" runat="server"
SelectMethod="GetEntity"
2 TypeName="GC.Finance.Web500.Data.EmployeeAdapter"
DataObjectTypeName="GC.Finance.Web500.Data.PSEmplo yee"
3 DeleteMethod="Delete" InsertMethod="Insert"
UpdateMethod="Update">
4 <SelectParameters>
5 <asp:QueryStringParameter Name="id" QueryStringField="empl"
Type="Int32" />
6 </SelectParameters Notice above that the DataObjectTypeName
is set to the PSEmployee object, thus making this a storngly-typed
ObjectDataSource. (This is the business ojbect described as the "Employee"
object above.) I did fine one example where a strongly-typed
ObjectDataSource 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="frmvwEmployeeMain" DataSourceID="odsEmployeeEdit"
runat="server">
2
3 <ItemTemplate>
4 <table id="tblMainInfo">
5 <tr>
6 <td class="TabArea" valign="top" style="text-align:
left">
7 <uc2:EmployeeOrg ID="EmployeeOrg1"
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:resourcekey="lblTitleEnResource1"
Text="Title (English):"></asp:Label></td>
15 <td colspan="3">
16 <asp:TextBox
ID="txtTitleEn" runat="server" meta:resourcekey="txtTitleEnResource1"
Text='<%# Bind("TitleEnglish") %>'></asp:TextBox></td>
17 </tr>
18 <tr>
19 <td style="height: 26px;
width: 114px;">
20 <asp:Label
ID="lblTitleFr" runat="server" meta:resourcekey="lblTitleFrResource1"
Text="Title (French):"></asp:Label></td>
21 <td colspan="3">
22 <asp:TextBox
ID="txtTitleFr" runat="server" meta:resourcekey="txtTitleFrResource1"
Text='<%# Bind("TitleFrench") %>'></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 DirectoryServicesAdapter
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 IDirectoryEntity) 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(empl, IDirectoryEntity))
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_EmployeeUpdate' 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.SqlClient.SqlException: Procedure
'sp_EmployeeUpdate' expects parameter '@surname', which was not supplied.

Source Error:

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

Source File: c:\inetpub\wwwroot\Update500\UserControls\Employee CRUD.ascx.vb
Line: 33

Stack Trace:

[SqlException (0x80131904): Procedure 'sp_EmployeeUpdate' expects parameter
'@surname', which was not supplied.]
System.Data.SqlClient.SqlConnection.OnError(SqlExc eption exception,
Boolean breakConnection) +857338
System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException
exception, Boolean breakConnection) +734950

System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject
stateObj) +188
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand
cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet
bulkCopyHandler, TdsParserStateObject stateObj) +1838
System.Data.SqlClient.SqlCommand.FinishExecuteRead er(SqlDataReader ds,
RunBehavior runBehavior, String resetOptionsString) +149
System.Data.SqlClient.SqlCommand.RunExecuteReaderT ds(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
+886
System.Data.SqlClient.SqlCommand.RunExecuteReader( CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method,
DbAsyncResult result) +132
System.Data.SqlClient.SqlCommand.InternalExecuteNo nQuery(DbAsyncResult
result, String methodName, Boolean sendToPipe) +415
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135
GC.Finance.Web500.Data.PSEmployee.Update() in C:\Documents and
Settings\rholder\My Documents\Visual Studio
2005\Projects\GC.Finance.X500.Data\GC.Finance.X500 .Data\Entities\PSEmployee.vb:211
GC.Finance.Web500.Data.EmployeeAdapter.Update(IDir ectoryEntity de) in
C:\Documents and Settings\rholder\My Documents\Visual Studio
2005\Projects\GC.Finance.X500.Data\GC.Finance.X500 .Data\Adapters\EmployeeAdapter.vb:80
GC.Finance.Web500.Data.EmployeeAdapter.Update(PSEm ployee empl) in
C:\Documents and Settings\rholder\My Documents\Visual Studio
2005\Projects\GC.Finance.X500.Data\GC.Finance.X500 .Data\Adapters\EmployeeAdapter.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 1677
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.Update is building the update command
properly

Gerry
"ross613" <ro*****@discussions.microsoft.comwrote in message
news:FF**********************************@microsof t.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
ObjectDataSource 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 ObjectDataSource control on the page:

1 <asp:ObjectDataSource ID="odsEmployeeEdit" runat="server"
SelectMethod="GetEntity"
2 TypeName="GC.Finance.Web500.Data.EmployeeAdapter"
DataObjectTypeName="GC.Finance.Web500.Data.PSEmplo yee"
3 DeleteMethod="Delete" InsertMethod="Insert"
UpdateMethod="Update">
4 <SelectParameters>
5 <asp:QueryStringParameter Name="id"
QueryStringField="empl"
Type="Int32" />
6 </SelectParameters Notice above that the DataObjectTypeName
is set to the PSEmployee object, thus making this a storngly-typed
ObjectDataSource. (This is the business ojbect described as the
"Employee"
object above.) I did fine one example where a strongly-typed
ObjectDataSource 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="frmvwEmployeeMain" DataSourceID="odsEmployeeEdit"
runat="server">
2
3 <ItemTemplate>
4 <table id="tblMainInfo">
5 <tr>
6 <td class="TabArea" valign="top"
style="text-align:
left">
7 <uc2:EmployeeOrg ID="EmployeeOrg1"
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:resourcekey="lblTitleEnResource1"
Text="Title (English):"></asp:Label></td>
15 <td colspan="3">
16 <asp:TextBox
ID="txtTitleEn" runat="server" meta:resourcekey="txtTitleEnResource1"
Text='<%# Bind("TitleEnglish") %>'></asp:TextBox></td>
17 </tr>
18 <tr>
19 <td style="height: 26px;
width: 114px;">
20 <asp:Label
ID="lblTitleFr" runat="server" meta:resourcekey="lblTitleFrResource1"
Text="Title (French):"></asp:Label></td>
21 <td colspan="3">
22 <asp:TextBox
ID="txtTitleFr" runat="server" meta:resourcekey="txtTitleFrResource1"
Text='<%# Bind("TitleFrench") %>'></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 DirectoryServicesAdapter
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 IDirectoryEntity) 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(empl, IDirectoryEntity))
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_EmployeeUpdate' 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.SqlClient.SqlException: Procedure
'sp_EmployeeUpdate' expects parameter '@surname', which was not supplied.

Source Error:

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

Source File:
c:\inetpub\wwwroot\Update500\UserControls\Employee CRUD.ascx.vb
Line: 33

Stack Trace:

[SqlException (0x80131904): Procedure 'sp_EmployeeUpdate' expects
parameter
'@surname', which was not supplied.]
System.Data.SqlClient.SqlConnection.OnError(SqlExc eption exception,
Boolean breakConnection) +857338
System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException
exception, Boolean breakConnection) +734950

System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject
stateObj) +188
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand
cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet
bulkCopyHandler, TdsParserStateObject stateObj) +1838
System.Data.SqlClient.SqlCommand.FinishExecuteRead er(SqlDataReader ds,
RunBehavior runBehavior, String resetOptionsString) +149
System.Data.SqlClient.SqlCommand.RunExecuteReaderT ds(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
+886
System.Data.SqlClient.SqlCommand.RunExecuteReader( CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method,
DbAsyncResult result) +132
System.Data.SqlClient.SqlCommand.InternalExecuteNo nQuery(DbAsyncResult
result, String methodName, Boolean sendToPipe) +415
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135
GC.Finance.Web500.Data.PSEmployee.Update() in C:\Documents and
Settings\rholder\My Documents\Visual Studio
2005\Projects\GC.Finance.X500.Data\GC.Finance.X500 .Data\Entities\PSEmployee.vb:211
GC.Finance.Web500.Data.EmployeeAdapter.Update(IDir ectoryEntity de) in
C:\Documents and Settings\rholder\My Documents\Visual Studio
2005\Projects\GC.Finance.X500.Data\GC.Finance.X500 .Data\Adapters\EmployeeAdapter.vb:80
GC.Finance.Web500.Data.EmployeeAdapter.Update(PSEm ployee empl) in
C:\Documents and Settings\rholder\My Documents\Visual Studio
2005\Projects\GC.Finance.X500.Data\GC.Finance.X500 .Data\Adapters\EmployeeAdapter.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
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...
28
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
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...
1
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...
7
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"...
2
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...
10
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...
1
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...
3
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...

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.