需要帮助来使用VB脚本从Excel表更新SQL表

先谢谢你。 我的目标是从Excel中更新SQL表。 所以我写了一个VBScript从一个单一的点击从my-sql获得SQL表。 表看起来像这样:

 ID规则长度是活动date
 1规则1 3 1 NULL
 2规则2 5 0 NULL
 3规则3 6 1 NULL
 4规则4 7 1 8/10/2015
 5规则5 3 0 NULL

现在我将更新lengthisactivedate字段和这个数据应该在表中更新在一个单一的点击。 请帮助我在这个脚本。 我试图更新查询失败与运行时错误 –

80040E14。

部分脚本是

 For iCount = 2 To 6 intRLength = CInt(objSheet.Cells(iCount, 3).Value) intID = CInt(objSheet.Cells(iCount, 1).Value) strQuerie = "UPDATE" & strDatabase & "." & strTable & "SET retentionlength=" & intRLenth & "where id= " & intID rs.Open strQuerie ' --- Getting run time error- 80040e14 message here Next 

这很可能是因为您的查询中某些部分的间距问题

你的查询应该看起来像

 strQuerie = "UPDATE " & strDatabase & "." & strTable & " SET retentionlength=" & intRLenth & " where id= " & intID 

否则,就目前来看, 你的查询看起来像下面哪个显然是错的

 UPDATEDB_NAME.TABLE_NAMESET retentionlength=somevaluewhere id= someid