Hresult = 0x80131515参数值 [英] Hresult=0x80131515 parameter value

查看:105
本文介绍了Hresult = 0x80131515参数值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在VB.NET的应用程序中工作。我陷入了这个错误:



System.NotSupportedException

HResult = 0x80131515

消息= BillTimeLibrary.BillTimeLibrary.Models.ClientModel类型的成员ClientId不能用作参数值





语境化.. 。

首先,我有同样的应用程序在C#中工作。我正在转换到VB.NET来学习和理解如何将SQLite数据库与Dapper一起使用这两种语言。



错误出现在参数的传递中来自连接我数据库中两个表的子例程。

Payments表有一个名为ClientId的Foreing Key,用于标识付款来自哪个客户。在付款窗口中,我有一个Combobox,我选择了客户端,如果有任何付款已经付款的日期列在另一个Combobox中。

当我选择时,该查询不起作用客户端程序应该通过ClientId获取平板电脑付款中的付款,但它会给出我上面提到的错误。

应该传递查询参数的子程序是:



 私有  Sub  LoadDateDropDown ()
Dim sql As String = select * from Payment,其中ClientId = @ClientId
Dim 参数作为字典( 字符串,对象)= 字典( 字符串对象)来自{
{ @ ClientId,ClientDropDown.SelectedValue}
}
Dim records = SQLiteDataAccess.LoadData( PaymentsModel)(sql,参数)
payments.Clear()
records.ForEach( Sub (x)payments.Add(x))
结束 Sub





消息在Load Sub中查看,它接收参数。





消息中提到的参数是在模型中创建的:它具有与数据库表中使用的相同类型的变量。 />


 进口系统
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Threading.Tasks


命名空间 BillTimeLibrary.Models
公共 PaymentsModel
< span class =code-keyword>公开 属性 Id 整数
公共 属性 ClientId As 整数
公共 物业小时作为 Double
公开 < span class =code-keyword>属性金额 Double
< span class =code-keyword> Public Property DatePayment As 字符串
结束
结束 命名空间







我想我可能正在使用ClientDropDown的错误属性(我的组合框)



请参阅C#中的原始代码:< br $>




 private void LoadDateDropDown()
{
string sql =select * from在ClientId = @ClientId的付款;

字典<字符串,对象> parameters = new Dictionary< string,object>
{
{@ ClientId,ClientDropDown.SelectedValue}
};

var records = SQLiteDataAccess.LoadData< PaymentsModel>(sql,parameters);

payments.Clear();
records.ForEach(x => payments.Add(x));
}





我的尝试:



我正在尝试通过ClientId字段查看如何访问付款表。还没有成功。



这是关于错误的完整细节..它似乎与Dapper有关。但由于我是新手,我不知道如何解决。



System.NotSupportedException

HResult = 0x80131515

Message = BillTimeLibrary.BillTimeLibrary.Models.ClientModel类型的成员ClientId不能用作参数值

Source = Dapper

StackTrace:<在C:\projects \ dadap \ Dapper \SqlMapper.cs:第417行中的Dapper.SqlMapper.LookupDbType(类型类型,字符串名称,布尔需求,ITypeHandler和处理程序)中的

在Dapper.DynamicParameters.AddParameters(IDbCommand命令,身份标识)中的C:\ project] \ dadper \ Dapper \DynamicParameters.cs:第238行

在Dapper.DynamicParameters .Dapper.SqlMapper中的.Dapper.SqlMapper.IDynamicParameters.AddParameters(IDbCommand命令,身份标识),位于C:\ project.dapper \ Dapper \DynamicParameters.cs:第156行

在C中的Dapper.CommandDefinition.SetupCommand(IDbConnection cnn,Action`2 paramReader) :\projects\dapper \ Dapper \CommandDefinition.cs:第128行

在Dapper.SqlMapper。< queryimpl> d__138`1.MoveNext()在C:\ project] \ dapper \ Dapper \SqlMapper.cs:第1075行

在System.Collections.Generic.List`1..ctor(IEnumerable`1集合)

在System。 Linq.Enumerable.ToList [TSource](IEnumerable`1 source)

在Dapper.SqlMapper.Query [T](IDbConnection cnn,String sql,Object param,IDbTransaction transaction,Boolean buffered,Nullable`1命令时间输出,Nullable`1 commandType)在C:\ projects \dapper \Dapper \SqlMapper.cs:第723行
illTimeLibrary.SQLiteDataAccess.LoadData [T](String sqlStatement,Dictionary` C:\BillTime_VB \BillTimeLibrary中的2个参数,String connectionName) \\ DataAccess\SQLiteDataAccess.vb:第25行

在BillTime_VB.Payments.LoadDateDropDown()中的C:\ BillTime_VB \BillTime_VB \Controls \ Payments.vb:第141行

at BillTime_VB.Payments.ClientDropDown_SelectedIndexChanged(Object sender,EventArgs e)在C:\ BillTime_VB \BillTime_VB \Controls \Payments.vb:第133行

在System.Windows。 Forms.ComboBox.OnSelectedIndexChanged(EventArgs e)

at System.Windows.Forms.ComboBox.set_SelectedIndex(Int32 value)

at System.Windows.Forms.ComboBox.RefreshItems(在System.Windows.Forms.Forms.Forbo.Forbo.Fors.OnDataSourceChanged(EventArgs e)上的


在System.Windows.Forms.ListControl.SetDataConnection(对象newDataSource,BindingMemberInfo newDisplayMember,布尔力)/ / $ $ $ $ $ $ $ $ $ $ $ ClientId?



从它的外观来看,你想使用ClientModel中的ClientId加载PaymentsModel。



似乎很清楚它没有'就像你传入的类型一样。


一些可能有用的提示:



1 )Google错误:HResult = 0x80131515,您会发现它会导致错误:无法加载文件或程序集。当然,问题是为什么它不能加载文件或程序集?



2 )仔细看看两行从您的来源 - 错误实际上指向他们作为原始原因:



1. Controls\Payments.vb:第133行

2. Controls\Payments.vb:第141行



在这里发布这两行,我可以提供更多帮助。

一些可能有用的提示:



1 )Google错误:HResult = 0x80131515你会发现它引导您出错:无法加载文件或程序集。当然,问题是为什么它不能加载文件或程序集?



2 )仔细看看两行从您的来源 - 错误实际上指向他们作为原始原因:



1. Controls\Payments.vb:第133行

2. Controls\Payments.vb:第141行



在这里发布这两行,我可以提供更多帮助。



3 )我还注意到错误状态:

BillTimeLibrary.BillTimeLibrary.Models类型的成员ClientId。 ClientModel 不能用作参数值。



但是你已经向我们展示了这个课程:

BillTimeLibrary.Models

公共类 PaymentsModel



如果您引用了错误类型的值,请不要错过?


Hi,

I am working in an application in VB.NET. I got stuck in this ERROR:

System.NotSupportedException
HResult=0x80131515
Message=The member ClientId of type BillTimeLibrary.BillTimeLibrary.Models.ClientModel cannot be used as a parameter value


Contextualizing...
First, I have this same application working in C#. I am converting to VB.NET to learn and understand how to use SQLite Database with Dapper with these both languages.

The error appears in the pass-through of a parameter from a sub routine that connects two tables from my database.
The Payments table has a Foreing Key named ClientId, which identifies which client the payment is from. In the payments window I have a Combobox where I choose the client, and if there is any payment already made the dates of the payments is listed in another Combobox.
That query is not working, when I choose the client the program should fetch the Payments in the Tablet Payments by the ClientId, but it gives that error that I mentioned above.
The subroutine that should pass the parameters for query is:

Private Sub LoadDateDropDown()
        Dim sql As String = "select * from Payment where ClientId = @ClientId"
        Dim parameters As Dictionary(Of String, Object) = New Dictionary(Of String, Object) From {
                {"@ClientId", ClientDropDown.SelectedValue}
            }
        Dim records = SQLiteDataAccess.LoadData(Of PaymentsModel)(sql, parameters)
        payments.Clear()
        records.ForEach(Sub(x) payments.Add(x))
    End Sub



the message is viewed in the Load Sub which receives the parameters.


The parameter it is mentioned in the message is created in a Model: it has the same type of variable used in the Database Table.

Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Threading.Tasks


Namespace BillTimeLibrary.Models
    Public Class PaymentsModel
        Public Property Id As Integer
        Public Property ClientId As Integer
        Public Property Hours As Double
        Public Property Amount As Double
        Public Property DatePayment As String
    End Class
End Namespace




I think I might be using the wrong property of the ClientDropDown (my combobox)

See the original code in the C#:


private void LoadDateDropDown()
        {
            string sql = "select * from Payment where ClientId = @ClientId";

        Dictionary<string, object> parameters = new Dictionary<string, object>
        {
            { "@ClientId", ClientDropDown.SelectedValue }
        };

        var records = SQLiteDataAccess.LoadData<PaymentsModel>(sql, parameters);

        payments.Clear();
        records.ForEach(x => payments.Add(x));
    }



What I have tried:

I am trying to see how to access the payments table through the ClientId Field. No success yet.

This is the FULL Details about the error.. it seems to be something with Dapper. But As I am new with it I do not know how to solve yet.

System.NotSupportedException
HResult=0x80131515
Message=The member ClientId of type BillTimeLibrary.BillTimeLibrary.Models.ClientModel cannot be used as a parameter value
Source=Dapper
StackTrace:
at Dapper.SqlMapper.LookupDbType(Type type, String name, Boolean demand, ITypeHandler& handler) in C:\projects\dapper\Dapper\SqlMapper.cs:line 417
at Dapper.DynamicParameters.AddParameters(IDbCommand command, Identity identity) in C:\projects\dapper\Dapper\DynamicParameters.cs:line 238
at Dapper.DynamicParameters.Dapper.SqlMapper.IDynamicParameters.AddParameters(IDbCommand command, Identity identity) in C:\projects\dapper\Dapper\DynamicParameters.cs:line 156
at Dapper.SqlMapper.<>c__DisplayClass161_0.<getcacheinfo>b__0(IDbCommand cmd, Object obj) in C:\projects\dapper\Dapper\SqlMapper.cs:line 1694
at Dapper.CommandDefinition.SetupCommand(IDbConnection cnn, Action`2 paramReader) in C:\projects\dapper\Dapper\CommandDefinition.cs:line 128
at Dapper.SqlMapper.<queryimpl>d__138`1.MoveNext() in C:\projects\dapper\Dapper\SqlMapper.cs:line 1075
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Dapper.SqlMapper.Query[T](IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Boolean buffered, Nullable`1 commandTimeout, Nullable`1 commandType) in C:\projects\dapper\Dapper\SqlMapper.cs:line 723
at BillTimeLibrary.SQLiteDataAccess.LoadData[T](String sqlStatement, Dictionary`2 parameters, String connectionName) in C:\BillTime_VB\BillTimeLibrary\DataAccess\SQLiteDataAccess.vb:line 25
at BillTime_VB.Payments.LoadDateDropDown() in C:\BillTime_VB\BillTime_VB\Controls\Payments.vb:line 141
at BillTime_VB.Payments.ClientDropDown_SelectedIndexChanged(Object sender, EventArgs e) in C:\BillTime_VB\BillTime_VB\Controls\Payments.vb:line 133
at System.Windows.Forms.ComboBox.OnSelectedIndexChanged(EventArgs e)
at System.Windows.Forms.ComboBox.set_SelectedIndex(Int32 value)
at System.Windows.Forms.ComboBox.RefreshItems()
at System.Windows.Forms.ComboBox.OnDataSourceChanged(EventArgs e)
at System.Windows.Forms.ListControl.SetDataConnection(Object newDataSource, BindingMemberInfo newDisplayMember, Boolean force)
at System.Windows.Forms.ListControl.set_DataSource(Object value)

解决方案

What's the "type" of ClientId?

From the looks of it, you want to load "PaymentsModel" using a "ClientId" from the "ClientModel".

It seems to be pretty clear that it doesn't like the "type" you're passing in.


A couple of hints that may help:

1) Google the error : HResult=0x80131515 and you will find that it leads you to the error : "Could not load file or assembly". Of course, the question is why can't it load the file or assembly?

2) Take a very close look at two lines from your source -- the error is actually pointing to them as the original cause:

1. Controls\Payments.vb:line 133
2. Controls\Payments.vb:line 141

Post those two lines here and I may be able to help more.


A couple of hints that may help:

1) Google the error : HResult=0x80131515 and you will find that it leads you to the error : "Could not load file or assembly". Of course, the question is why can't it load the file or assembly?

2) Take a very close look at two lines from your source -- the error is actually pointing to them as the original cause:

1. Controls\Payments.vb:line 133
2. Controls\Payments.vb:line 141

Post those two lines here and I may be able to help more.

3) I also notice that the error states:
The member ClientId of type BillTimeLibrary.BillTimeLibrary.Models.ClientModel cannot be used as a parameter value.

But you have shown us the class :
BillTimeLibrary.Models
Public Class PaymentsModel

Wonder if you're referencing the value in the wrong type??


这篇关于Hresult = 0x80131515参数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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