我需要命令来通过C#.net usind ADO更新M Access数据库
it1352
帮助3人
问题说明
我正在使用visual studio框架来使用ado.net连接来操作我的数据库这是我的更新声明
i am working on visual studio framework to manipulate my database using ado.net connectivity this is my update statement
string stdupdt = "update std set name='" txtNM.Text "' ,addr= '" txtAD.Text "' where id='" txtID.Text "'";
这句话有什么问题请
what is wrong with this statement please
正确答案
#1
什么都不知道关于你得到的错误消息,很难确定,但是......
可能你问题是数据库定义 - 你用过访问保留字 [ ^ ]作为列名,当您尝试更新时,这很可能会混淆Access,因为它不希望在该上下文中看到该单词。 />
在这种情况下,你不应该将任何列命名为name - 如果你这样做,那么你需要将它括在方括号中:
Without knowing anything about teh error message you get, it is very difficult to be sure, but...
Probably, you problem is to do with the database definition - you have used an Access reserved word[^] as a column name, and this is likely to confuse Access when you try to update as it isn''t expecting to see the word in that context.
In this case, you should not name any column "name" - if you do, then you need to enclose it in square brackets:
string stdupdt = "update std set [name]='" txtNM.Text "' ,addr= '" txtAD.Text "' where id='" txtID.Text "'";
确保Id不是数字。
尝试并调试此代码。执行到此行时,选择查询,粘贴到管理工作室并运行它。
查看您获得的错误类型。它应该让你更好地了解如何解决这个问题。
另请注意,将参数直接传递给查询可能会导致安全问题。
尝试并使用参数 - http://csharp-station.com/Tutorial/AdoDotNet/Lesson06 [ ^ ]。
Make sure Id is not numeric.
Try and debug this code. When execution comes to this line, pick up the query, paste in management studio and run it.
See what type of error you get. It should give you a better idea of how to fix this problem.
Also note that passing parameters directly into a query can lead to security concerns.
Try and use parameters - http://csharp-station.com/Tutorial/AdoDotNet/Lesson06[^].
这篇好文章是转载于:编程之路
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 编程之路
- 本文地址: /reply/detail/tanhcakhih
系列文章
更多
同类精品
更多
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
使用c++17更新时出现G++编译器警告
it1352 06-18 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
复制文件夹/文件而不修改属性?
it1352 07-15 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20 -
Android微调工具-删除当前选择
it1352 06-20