ASP.NET 2.0 ObjectDataSource UpdateMethod未传递新值 [英] ASP.NET 2.0 ObjectDataSource UpdateMethod not passing new values

查看:53
本文介绍了ASP.NET 2.0 ObjectDataSource UpdateMethod未传递新值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我今天开始使用ObjectDataSource。我有选择,

,并一直在努力让更新方法工作。这是

我的数据源的asp代码:


< asp:ObjectDataSource ID =" dsourceApps" runat =" server"

SelectMethod =" getAllApplications"

TypeName =" AppMgr.AppManager" UpdateMethod =" updateAppHdr"

ConflictDetection =" CompareAllValues"

OldValuesParameterFormatString =" {0} _old"

OnObjectCreating =" dsourceApps_OnObjectCreating" ;

OnObjectDisposing =" dsourceApps_OnObjectDisposing">

< UpdateParameters>

< asp:Parameter Name =" appid"类型="字符串" />

< asp:参数名称=" appname"类型="字符串" />

< asp:参数名称=" apploc"类型="字符串" />

< asp:参数名称=" appdesc"类型="字符串" />

< asp:参数名称=" appid_old"类型="字符串" />

< asp:参数名称=" appname_old"类型="字符串" />

< asp:参数名称=" apploc_old"类型="字符串" />

< asp:参数名称=" appdesc_old"类型="字符串" />

< / UpdateParameters>

< / asp:ObjectDataSource>

updateAppHdr函数的函数sig为:


public void updateAppHdr(string appid,string appname,string apploc,

string appdesc,string appid_old,string appname_old,string

apploc_old ,字符串appdesc_old)


我在GridView中编辑字段

后点击保存按钮后得到的错误是:


异常详细信息:System.Data.OracleClient.OracleException:ORA-06550:

第1行,第7列:

PLS-00306:错误的数字或调用的参数类型

''ND_UPD_DEFINED_APP''

ORA-06550:第1行第7列:

PL / SQL:Statement忽略了

我做了一些挖掘工作,我注意到所有新值(没有附加_old的

字段)都作为NULL进入函数。

旧的价值正在好转,但是新值只是

null ...


任何想法为什么会这样?它实际上进入了

函数,所以我猜它与

gridview的设置方式有关......我可以'似乎在谷歌上找不到任何东西,

或者我不知道该找什么...


提前致谢任何帮助,

Mike

解决方案

在UpdateAppHdr函数中,您可以尝试将值设置为默认值(如果

,它们为空),然后将它们传递给Oracle,看看是否消除了

ORA异常?


-

HTH,

Phillip Williams
http://www.societopia.net
http://www.webswapp .com

" an ******* @ gmail.com"写道:

您好,

我今天开始使用ObjectDataSource。我有选择,
并一直在努力让更新方法工作。这是我的数据源的asp代码:

< asp:ObjectDataSource ID =" dsourceApps" runat =" server"
SelectMethod =" getAllApplications"
TypeName =" AppMgr.AppManager" UpdateMethod =" updateAppHdr"
ConflictDetection =" CompareAllValues"
OldValuesParameterFormatString =" {0} _old"
OnObjectCreating =" dsourceApps_OnObjectCreating"
OnObjectDisposing =" dsourceApps_OnObjectDisposing"> ;
< UpdateParameters>
< asp:Parameter Name =" appid"类型="字符串" />
< asp:参数名称=" appname"类型="字符串" />
< asp:参数名称=" apploc"类型="字符串" />
< asp:参数名称=" appdesc"类型="字符串" />
< asp:参数名称=" appid_old"类型="字符串" />
< asp:参数名称=" appname_old"类型="字符串" />
< asp:参数名称=" apploc_old"类型="字符串" />
< asp:参数名称=" appdesc_old"类型="字符串" />
< / UpdateParameters>
< / asp:ObjectDataSource>

updateAppHdr函数的函数sig为:

public void updateAppHdr(string appid,string appname,string apploc,
string appdesc,string appid_old,string appname_old,string
apploc_old,string appdesc_old)

我点击后得到的错误在我的GridView中编辑字段后的保存按钮是:

异常详细信息:System.Data.OracleClient.OracleException:ORA-06550:
第1行,第7列:< PLS-00306:调用
''ND_UPD_DEFINED_APP'的参数的数量或类型错误。
ORA-06550:第1行第7列:
PL / SQL:语句被忽略

我做了一些挖掘工作,我注意到所有新值(没有附加_old的
字段)都作为NULL进入函数。
旧的价值观正在进入,但新的价值只是空的......

任何想法为什么这发生了什么?它实际上正在进入
功能,所以我猜它与
gridview的设置方式有关...我似乎找不到任何关于这个的东西在google上,
或者我只是不确定要找什么...

提前感谢您的帮助,
Mike


谢谢Phillip,我离开了几天或者我早就回复了




我做了你的建议,在进行更新的功能中,我前进了
并硬编码了new的一些值。字段(绕过

NULL'即将进入)并且存储的proc触发并执行只需

罚款。


问题必须是null'被传入,但我不能

似乎跟踪它了。还有什么建议吗?


谢谢,

迈克


欢迎回来迈克。


我的第一个猜测就是双向数据绑定。如果数据绑定服务器控件不是使用双向数据绑定的
,则ObjectDataSource将为参数值传递null。如果您在GridView中使用了itemtemplates

,并且使用Eval方法而不是Bind绑定了控件,例如:

< asp:TextBox ID =" txtapploc" RUNAT = QUOT;服务器" Text =''<%#Eval(" apploc"")

%>''>< / asp:TextBox>


-

HTH,

Phillip Williams
http://www.societopia.net
http:// www.webswapp.com

" Mike"写道:

感谢Phillip,我离开了几天或者我会早点回复

我做了你的建议,在进行更新的功能,我前进了,并为新的硬编码了一些值。字段(绕过即将进入的
NULL)和存储的proc触发并执行就好了。

问题必须是null''传入,但我似乎无法追踪它。还有其他建议吗?

谢谢,
Mike



Hello,

I started working with the ObjectDataSource today. I have the select,
and have been working on getting the update method to work. Here is
the asp code for my Data source:

<asp:ObjectDataSource ID="dsourceApps" runat="server"
SelectMethod="getAllApplications"
TypeName="AppMgr.AppManager" UpdateMethod="updateAppHdr"
ConflictDetection="CompareAllValues"
OldValuesParameterFormatString="{0}_old"
OnObjectCreating="dsourceApps_OnObjectCreating"
OnObjectDisposing="dsourceApps_OnObjectDisposing">
<UpdateParameters>
<asp:Parameter Name="appid" Type="String" />
<asp:Parameter Name="appname" Type="String" />
<asp:Parameter Name="apploc" Type="String" />
<asp:Parameter Name="appdesc" Type="String" />
<asp:Parameter Name="appid_old" Type="String" />
<asp:Parameter Name="appname_old" Type="String" />
<asp:Parameter Name="apploc_old" Type="String" />
<asp:Parameter Name="appdesc_old" Type="String" />
</UpdateParameters>
</asp:ObjectDataSource>
The function sig for the updateAppHdr function is:

public void updateAppHdr(string appid, string appname, string apploc,
string appdesc, string appid_old, string appname_old, string
apploc_old, string appdesc_old)

The error that I get after I hit the save button after editing a field
in my GridView is:

Exception Details: System.Data.OracleClient.OracleException: ORA-06550:
line 1, column 7:
PLS-00306: wrong number or types of arguments in call to
''ND_UPD_DEFINED_APP''
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
I did some digging, and I''m noticing that all the new values (the
fields without "_old" appended) are coming into the function as NULL.
The old values are coming in properly, but the new values are just
null...

Any ideas why this is happening? It''s actually getting into the
function, so I''m guessing it has something to do with the way the
gridview is setup... I can''t seem to find anything on this on google,
or maybe I''m just not sure what to look for...

Thanks in advance for any help,
Mike

解决方案

In the UpdateAppHdr function can you try setting the values to defaults (if
they were null) before passing them to Oracle and see if that eliminates the
ORA exception?

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"an*******@gmail.com" wrote:

Hello,

I started working with the ObjectDataSource today. I have the select,
and have been working on getting the update method to work. Here is
the asp code for my Data source:

<asp:ObjectDataSource ID="dsourceApps" runat="server"
SelectMethod="getAllApplications"
TypeName="AppMgr.AppManager" UpdateMethod="updateAppHdr"
ConflictDetection="CompareAllValues"
OldValuesParameterFormatString="{0}_old"
OnObjectCreating="dsourceApps_OnObjectCreating"
OnObjectDisposing="dsourceApps_OnObjectDisposing">
<UpdateParameters>
<asp:Parameter Name="appid" Type="String" />
<asp:Parameter Name="appname" Type="String" />
<asp:Parameter Name="apploc" Type="String" />
<asp:Parameter Name="appdesc" Type="String" />
<asp:Parameter Name="appid_old" Type="String" />
<asp:Parameter Name="appname_old" Type="String" />
<asp:Parameter Name="apploc_old" Type="String" />
<asp:Parameter Name="appdesc_old" Type="String" />
</UpdateParameters>
</asp:ObjectDataSource>
The function sig for the updateAppHdr function is:

public void updateAppHdr(string appid, string appname, string apploc,
string appdesc, string appid_old, string appname_old, string
apploc_old, string appdesc_old)

The error that I get after I hit the save button after editing a field
in my GridView is:

Exception Details: System.Data.OracleClient.OracleException: ORA-06550:
line 1, column 7:
PLS-00306: wrong number or types of arguments in call to
''ND_UPD_DEFINED_APP''
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
I did some digging, and I''m noticing that all the new values (the
fields without "_old" appended) are coming into the function as NULL.
The old values are coming in properly, but the new values are just
null...

Any ideas why this is happening? It''s actually getting into the
function, so I''m guessing it has something to do with the way the
gridview is setup... I can''t seem to find anything on this on google,
or maybe I''m just not sure what to look for...

Thanks in advance for any help,
Mike



Thanks Phillip, I was away for a few days or I would have replied
sooner.

I did what you suggested, in the function to do the update, I went
ahead and hardcoded some values for the "new" fields (bypassing the
NULL''s that were coming in) and the stored proc fired and executed just
fine.

The problem has to be with the null''s getting passed in, but I can''t
seem to track it down yet. Any more suggestions?

Thanks,
Mike


Welcome back Mike.

My first guess would be the 2-way databinding. The ObjectDataSource would
pass null for the parameter values if the databound server control was not
using 2-way databinding, e.g. if you had used itemtemplates in the GridView
with controls bound using the Eval method instead of the Bind, e.g.:
<asp:TextBox ID="txtapploc" runat="server" Text=''<%# Eval("apploc"")
%>''></asp:TextBox>

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Mike" wrote:

Thanks Phillip, I was away for a few days or I would have replied
sooner.

I did what you suggested, in the function to do the update, I went
ahead and hardcoded some values for the "new" fields (bypassing the
NULL''s that were coming in) and the stored proc fired and executed just
fine.

The problem has to be with the null''s getting passed in, but I can''t
seem to track it down yet. Any more suggestions?

Thanks,
Mike



这篇关于ASP.NET 2.0 ObjectDataSource UpdateMethod未传递新值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆