数据类型MS Accss2010中的条件表达式不匹配 [英] Data type Mismatch in criteria expression in MS Accss2010

查看:65
本文介绍了数据类型MS Accss2010中的条件表达式不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试过执行INSERT查询,但是它抛出了上面的错误。我在下面给出了我的代码



I tried execute INSERT query, but it throwing above error. I have given my code below

public string InsertMoveDetails(string desc, string currentLocation, string newLocation, string newBay, string requestedBy, string movedBy, string approvedBy, DateTime dateOfMove)
    {

string desc, currentLocation, newLocation, movedBy, approvedBy, requestedBy,newBay;
        DateTime dateOfMove;

        desc = textBoxDescription.Text;
        currentLocation = textBoxCurrentLocation.Text;
        newLocation = comboBoxNewLocation.Text;
        movedBy = comboBoxMovedBy.Text;
        approvedBy = comboBoxApprovedBy.Text;
        dateOfMove = dateTimePickerDateOfMove.Value;           
        newBay = textBoxNewBay.Text;
        requestedBy = textBoxRequestedBy.Text;

        con.Open();
        OleDbCommand cmd1 = new OleDbCommand("INSERT INTO MoveDetails(Descrptn, CurrentLocation, NewLocation, NewBay, RequestedBy, MovedBy, ApprovedBy, DateOfMove) VALUES(@Descrptn, @CurrentLocation, @NewLocation, @NewBay, @RequestedBy, @MovedBy, @ApprovedBy, @DateOfMove)", con);

        cmd1.Parameters.AddWithValue("@Descrptn", desc);
        cmd1.Parameters.AddWithValue("@CurrentLocation", currentLocation);
        cmd1.Parameters.AddWithValue("@NewLocation", newLocation);
        cmd1.Parameters.AddWithValue("@NewBay", newBay);
        cmd1.Parameters.AddWithValue("@RequestedBy", requestedBy);
        cmd1.Parameters.AddWithValue("@MovedBy", movedBy);
        cmd1.Parameters.AddWithValue("@ApprovedBy", approvedBy);
        cmd1.Parameters.AddWithValue("@DateOfMove", dateOfMove);

        cmd1.ExecuteNonQuery();
        con.Close();
        return "";
    }





我的数据库设计是

描述文字

CurrentLocation-文字

NewLocation-文字

NewBay-文字

请求文本

MovedBy-文字

ApprovedBy-文件

DateOfMove-日期/时间



请帮我解决此错误。我尝试了其他线程有相同的错误,但我找不到答案。



My database design is
Descrptn- Text
CurrentLocation- Text
NewLocation- Text
NewBay- Text
RequestedBy- Text
MovedBy- Text
ApprovedBy- Text
DateOfMove- Date/Time

Please help me with this error. I tried the other threads with same error, but i can't find the answer.

推荐答案

对我来说没有什么明显的:数据类型看起来正确 - 只留下数据。



所以从调试器开始吧。

在断线上放一个断点:

There is nothing obvious to me in that: the data types look right - which leaves only the data.

So start with the debugger.
Put a breakpoint on the line:
cmd1.ExecuteNonQuery();

并运行你的应用程序。

当它到达断点时,它将停止。然后,您可以查看要加载到每个参数中的数据,并确切了解它们的含义。猜测,日期是在SQL限制之外,或者其他一个字段返回一个数据库中不允许的值 - 可能是null或太大的字符串。



但是没有实际数据?我很害怕,我们无能为力。

And run your app.
When it hits the breakpoint, it will stop. You can then look at the data you are loading into each parameter and see exactly what they are. At a guess, either the date is outside SQL limits, or one of the other fields is returning a value which isn't allowed in your DB - a null, or too large a string perhaps.

But without the actual data? Nothing we can do to help, I'm afraid.


我试过这段代码。



I tried with this code.

dateOfMove = Convert.ToDateTime(dateTimePickerDateOfMove.Text);



这对我有用。


That's works for me.


这篇关于数据类型MS Accss2010中的条件表达式不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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