关于OleDb更新错误的说明 [英] WHAT ABOUT THE OleDb update error

查看:99
本文介绍了关于OleDb更新错误的说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

再次出现,我正在尝试使用OleDb更新访问数据库中的一些小内容.
知道我有此代码:

Hay there again Im trying to update some small stuff in a access database using the OleDb.
Know I have this code:

string command = ("UPDATE Users SET Id="+"'"+user+"'"+", User="+"'"+password+"'"+"WHERE Id="+"<"+Opassword+">");
            c = new OleDbCommand(command, con);
            ap.UpdateCommand = c;
            con.ConnectionString = conection;
            using(con)
            {
                c.Connection = con;
                con.Open();
                ap.UpdateCommand.ExecuteNonQuery();                
            }
            ap.Dispose();
            con.Close();



知道我收到的唯一错误是一个简单的您在UPDATE命令上出现Sysntax错误",它不会因为根本不执行它而区分.

我该如何解决这个问题,或者解决该问题的正确方法是什么?



Know the onle error I receive is a simple "You had a Sysntax error on your UPDATE command" it doesnt sepecify in what it simply doesnt execute it.

How may I fix this, or what is the correct way to deal with this ?

推荐答案

假设您正在使用SQL Server!
在代码中放置一个断点,然后查看您要执行的字符串.
将字符串复制到SSMS并尝试执行.

我怀疑使用"<"+Opassword+">"而不是"["+Opassword+"]"可能是错误.或您的变量之一不正确或缺失.

了解如何使用实用的查询,它们将使您的生活更加简单.
Assuming you are using SQL server!
Put a break point in your code and look at the string you are trying to execute.
Copy the string to SSMS and try and execute it.

I suspect the use of "<"+Opassword+">" instead of "["+Opassword+"]" may be the error. Or one of your variables is incorrect or missing.

Learn how to use prameterised queries, they will make you life DRAMATICALLY simpler.


这篇关于关于OleDb更新错误的说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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