使用vb.net更新数据库所需的帮助 [英] help needed to update database using vb.net

查看:165
本文介绍了使用vb.net更新数据库所需的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

im尝试使用vb.net更新我的ms Access数据库中的表.我曾尝试使用命令生成器,但每次运行代码时,都会出现错误,提示"UPDATE语句中的语法错误"

如何解决此问题以成功更新ms数据库?

这是我的代码:

im trying to update a table in my ms access database using vb.net. i have tried using the command builder but everytime i rune the code i get an error it says "Syntax error in UPDATE statement"

how can i fix this to successfully updae the ms database?

here is my code:

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

       Dim ca As New OleDb.OleDbCommandBuilder(da)


       ds.Tables("s").Rows(inc).Item(1) = TextBox2.Text
       ds.Tables("s").Rows(inc).Item(2) = TextBox3.Text
       ds.Tables("s").Rows(inc).Item(3) = TextBox4.Text
       ds.Tables("s").Rows(inc).Item(4) = TextBox5.Text
       ds.Tables("s").Rows(inc).Item(5) = TextBox6.Text
       ds.Tables("s").Rows(inc).Item(6) = TextBox7.Text
       ds.Tables("s").Rows(inc).Item(7) = TextBox8.Text
       ds.Tables("s").Rows(inc).Item(8) = TextBox9.Text

       da.Update(ds, "s")


       MsgBox("updated")



感谢所有帮助.

Thanks



all help appreciated.

thanks

推荐答案

Access Update查询中的常见问题之一是ID严格是Access中的Text类型,而C#中是字符串.

即使Access从内部接受了它,但是如果从程序中调用它,Access也不喜欢将Found作为列名.您需要更改列的名称并相应地对其进行引用才能成功执行.
One of the common issue in Access Update query is that ID is strictly a Text type in Access, string in C#.

Even though Access accepted it from the inside, if called from the program, Access dislikes Found as a column name. You need change the name of the column and referenced it accordingly to execute successfully.


这篇关于使用vb.net更新数据库所需的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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