• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

我需要命令来通过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
系列文章
更多 icon
同类精品
更多 icon
继续加载