条件表达式中的数据类型不匹配。

编程入门 行业动态 更新时间:2024-10-17 05:30:29
本文介绍了条件表达式中的数据类型不匹配。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

嗨朋友们, 我试图通过访问表中的参数添加数值,我收到上述消息。什么是解决方案,我尝试如下: 我尝试过的事情: Sub DataTrans() Dbconnection.Open() MasterReader = MasterCmd.ExecuteReader() 试试 MasterReader.Read() IntArr(0)=(MasterReader(Sap_No)) IntArr(1)=(MasterReader(DesigIndex)) IntArr(2)=(MasterReader) (CurrYear)) StrArr(0)=(MasterReader(CPF_No.ToString)) StrArr(1)= (MasterReader(Name.ToString)) StrArr(2)=(MasterReader(指定.ToString)) LvMasterCmd.CommandText =INSERT INTO LeaveMaster(CPF_No,Name,Designation,MNT,YR,LeaveStatus,CurrYear,Sap_No,DesigIndex)& VALUES(@ CPF_No,@ Name,@ Designation,@ MNT,@ YR,@ LeaveStatus,CurrYear,@ Sap_No,@ DesigIndex); 尝试 LvMasterCmd.Parameters.AddWithValue(@ Sap_No,IntArr(0)) LvMasterCmd.Parameters.AddWithValue(@ DesigIndex,IntArr(1)) LvMasterCmd.Parameters.AddWithValue(@ CurrYear ,IntArr(2)) LvMasterCmd.Parameters.AddWithValue(@ CPF_No,StrArr(0).ToString) LvMasterCmd。 Parameters.AddWithValue(@ Name,StrArr(1).ToString) LvMasterCmd.Parameters.AddWithValue(@ Designation,StrArr(2).ToString) LvMasterCmd.Parameters.AddWithValue(@ MNT,CmbMonth.Text) LvMasterCmd.Parameters.AddWithValue(@ YR,CmbYear.Text) LvMasterCmd.Parameters.AddWithValue(@ LeaveStatus,N) LvMasterCmd.Exe cuteNonQuery() LvMasterCmd.Parameters.Clear() Catch ex As Exception MessageBox.Show(ex.Message) 结束尝试 结束时 Catch ex As Exception MessageBox.Show(ex.Message) 结束尝试 Dbconnection.Close() 结束Sub

Hi friends, I am trying to add numerical value through parameter in access table, I receive aforesaid message. what will be the solution, I have tried as follows: What I have tried: Sub DataTrans() Dbconnection.Open() MasterReader = MasterCmd.ExecuteReader() Try While MasterReader.Read() IntArr(0) = (MasterReader("Sap_No")) IntArr(1) = (MasterReader("DesigIndex")) IntArr(2) = (MasterReader("CurrYear")) StrArr(0) = (MasterReader("CPF_No".ToString)) StrArr(1) = (MasterReader("Name".ToString)) StrArr(2) = (MasterReader("Designation".ToString)) LvMasterCmd.CommandText = "INSERT INTO LeaveMaster (CPF_No, Name, Designation, MNT, YR, LeaveStatus,CurrYear,Sap_No,DesigIndex)" & "VALUES (@CPF_No, @Name, @Designation, @MNT, @YR, @LeaveStatus, CurrYear, @Sap_No, @DesigIndex) ; " Try LvMasterCmd.Parameters.AddWithValue("@Sap_No", IntArr(0)) LvMasterCmd.Parameters.AddWithValue("@DesigIndex", IntArr(1)) LvMasterCmd.Parameters.AddWithValue("@CurrYear", IntArr(2)) LvMasterCmd.Parameters.AddWithValue("@CPF_No", StrArr(0).ToString) LvMasterCmd.Parameters.AddWithValue("@Name", StrArr(1).ToString) LvMasterCmd.Parameters.AddWithValue("@Designation", StrArr(2).ToString) LvMasterCmd.Parameters.AddWithValue("@MNT", CmbMonth.Text) LvMasterCmd.Parameters.AddWithValue("@YR", CmbYear.Text) LvMasterCmd.Parameters.AddWithValue("@LeaveStatus", "N") LvMasterCmd.ExecuteNonQuery() LvMasterCmd.Parameters.Clear() Catch ex As Exception MessageBox.Show(ex.Message) End Try End While Catch ex As Exception MessageBox.Show(ex.Message) End Try Dbconnection.Close() End Sub

推荐答案

我们无法帮助:这主要取决于您的数据和数据库的设计,我们也无法访问。 所以,这取决于你。 幸运的是,你有一个可用的工具你将帮助你找出发生了什么:调试器。你如何使用它取决于你的编译器系统,但是一个快速的谷歌用于你的IDE名称和调试器应该给你你需要的信息。 放一个行上的断点 We can't help: this is going to be largely down to your data, and the design of your database, and we have no access to either. So, it's going to be up to you. Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. How you use it depends on your compiler system, but a quick Google for the name of your IDE and "debugger" should give you the info you need. Put a breakpoint on the line LvMasterCmd.Parameters.AddWithValue("@Sap_No", IntArr(0))

然后通过调试器运行代码。当它命中时,使用调试器来查看您传递给DB的确切内容。然后检查数据库表定义并检查该列所期望的数据类型。如果它不匹配,那就是当你遇到问题时,你可以回溯(或者再次运行它并仔细观察)以找出原因。 很抱歉,但我们不能为你做到这一点 - 时间让你学习一门新的(非常非常有用的)技能:调试!

Then run your code through the debugger. When it hits, use the debugger to look at exactly what you are passing to the DB. Then check the DB table definition and check what datatype that column expects. When it doesn't match, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why. Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!

更多推荐

条件表达式中的数据类型不匹配。

本文发布于:2023-11-22 14:41:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1617850.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表达式   数据类型   不匹配   条件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!