我使用数据集并且我正确地做了所有事情,字段作为数据库字段 但是这个消息总是出现给我: 编译错误 描述:编译服务此请求所需的资源时出错。请查看以下特定错误详细信息并相应地修改源代码。 编译器错误消息:CS1502:'KutubDataSetTableAdapters.BooksTableAdapter.InsertBook(字符串,字符串,十进制?,int?,int?,ref int)的最佳重载方法匹配?)'有一些无效的论点
I work with data set and I did every thing correctly, the fields as the Database fields but always this message appears to me: Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS1502: The best overloaded method match for 'KutubDataSetTableAdapters.BooksTableAdapter.InsertBook(string, string, decimal?, int?, int?, ref int?)' has some invalid arguments
int InsertBook(string BookName, string Description, int Price, int Publisher, int Category, int PublishDate) { KutubDataSetTableAdapters.BooksTableAdapter Bta = new KutubDataSetTableAdapters.BooksTableAdapter(); return Bta.InsertBook(BookName, Description, Price, Publisher, Category, PublishDate);} }我试图用这个:
I tried to use this:
int InsertBook(string BookName, string Description, decumal? Price, int? Publisher, int? Category,ref int? PublishDate)它没有成功..
And it didn't success..
推荐答案在传入参数时需要指定 ref 修饰符,但不要重新声明参数类型。 此外,参数传递为 ref 或 out 必须完全匹配声明的类型。你不能将 ref int 传递给 ref int?参数,所以你需要使用临时的本地变量。 试试这个: You need to specify the ref modifier when you pass the parameter in, but you don't re-state the argument types. Also, arguments passed as ref or out must match the declared type exactly. You can't pass a ref int to a ref int? parameter, so you'll to use need a temporary local variable. Try this: int? thePublishDate = PublishDate; return Bta.InsertBook(BookName, Description, Price, Publisher, Category, ref thePublishDate);
查看您的外部过程中的变量Price是否正在传递一个int数据类型,但您的另一个方法是期望可以为空的十进制小数?你不能为一个可空的内容交换一个int。 同样的逻辑适用于你的其他几个参数,特别是int和int?。这些数据类型不同。 stackoverflow/questions/6389437/explanation-of-int-vs-int [ ^ ] Look at your variable Price in your outer procedure you are passing an int datatype but your other method is expecting a nullable decimal, decimal?. You cannot interchange an int for a nullable. And the same logic applies to several of your other parameters, specifically the int and the int?. These are not the same data type. stackoverflow/questions/6389437/explanation-of-int-vs-int[^]
更多推荐
如何解决最好的重载方法匹配有一些无效的参数数据集
发布评论