ObjectDataSource.Insert 始终返回 -1
为了获取新的行 ID,我到处寻找并尝试了似乎对其他人都有效的通用解决方案。我无法更改数据库,但我确实知道参数 VersionID 是使用范围 Identity 设置的。 SP 中的最后一行是 return(@@VersionID) 我也尝试将其放在插入的事件上,
protected void VersionDataSource_Inserted(object sender, ObjectDataSourceStatusEventArgs e)
{
int returnValue = (int)e.OutputParameters;
}
但它总是返回 -1,我似乎无法获取新的行 ID,我也尝试过使参数 Direction 输出作为返回值。完全不知所措,一整天都在这些废话上。
Trying to get the new row ID, I have looked everywhere and tried the common solutions that seem to work for everyone else. I cannot change the database, but I do know that parameter VersionID is set with a scope Identity. the last line in the SP is return(@@VersionID) I have also tried putting this on the inserted event
protected void VersionDataSource_Inserted(object sender, ObjectDataSourceStatusEventArgs e)
{
int returnValue = (int)e.OutputParameters;
}
however it always returns -1, I cannot seem to get the new row ID, I have tried making the parameter Direction output as well as returnValue. At a total loss, have spent the whole day on this crap.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议输出参数似乎是一本字典
It seems the Outputparameters is a dictionary, I would suggest
您还没有发布标记,但是您应该有一个定义为输出参数的参数:
通过上述内容,您应该能够获得如下输出值:
You haven't posted the markup, but you should have a parameter defined as an output parameter:
With the above, you should be able to get the outputted value like this: