我们项目中需要的紧急帮助 [英] Urgent Help Needed in our Project

查看:55
本文介绍了我们项目中需要的紧急帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨. .我正在尝试运行这部分代码,但问题是它没有更新我的访问数据库

Hey hi . . i am trying to run this part of code but problem is that it is not updating my access database

con1.Open();
               
System.Data.OleDb.OleDbCommand cmd1 = new System.Data.OleDb.OleDbCommand(command, con1);
                
cmd1.ExecuteNonQuery();


System.Data.OleDb.OleDbCommand cmd2 = new System.Data.OleDb.OleDbCommand("UPDATE * from " + table_name + " order by Name", con1);

cmd2.ExecuteNonQuery();

con1.Close();



我们正在读取.mdb文件,并尝试对其进行排序. .但它不是排序:(



We are reading .mdb file and trying to sort it . . but it is not sorting :(

推荐答案

您应该使用以下代码:
You should be using the following :
System.Data.OleDb.OleDbCommand cmd2 = new System.Data.OleDb.OleDbCommand("SELECT * from " + table_name + " order by Name", con1);


有关在访问中使用Update语句的信息,请参阅以下链接.
UPDATE语句(Microsoft Access SQL) [
Refer to the following link on using Update statement with access.
UPDATE Statement (Microsoft Access SQL)[^]

also, looking at your update statement there is no set clause or where clause, what is it updating ?


不知道您要在cmd1中传递什么命令(它也不会",在这种情况下无关紧要),但仅允许将ORDER BY语句与SELECT命令关联使用.

使用
Don''t know what command you''re passing in cmd1 (it also doesn''t matter in this case) but using the ORDER BY Statement is only allowed in association with SELECT command.

Using
"SELECT * from " + table_name + " ORDER BY Name", con1

应该适合您.

使用SQL命令时请注意大写,这样一来便可读.

问候

should work for you.

Please take care of capitalization when using SQL Commands, it''s clearly readable then.

Regards


这篇关于我们项目中需要的紧急帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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