本文介绍了更新数据库不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用sqlheper从excel文件插入和更新行使用for to
I using sqlheper to insert and update rows from excel file using for to do
For i As Integer = 0 To dt.Rows.Count - 1
m12 = CDec("0" & dt.Rows(i)(14).ToString().Replace(".", ","))
m11 = CDec("0" & dt.Rows(i)(13).ToString().Replace(".", ","))
m10 = CDec("0" & dt.Rows(i)(12).ToString().Replace(".", ","))
m9 = CDec("0" & dt.Rows(i)(11).ToString().Replace(".", ","))
m8 = CDec("0" & dt.Rows(i)(10).ToString().Replace(".", ","))
m7 = CDec("0" & dt.Rows(i)(9).ToString().Replace(".", ","))
m6 = CDec("0" & dt.Rows(i)(8).ToString().Replace(".", ","))
m5 = CDec("0" & dt.Rows(i)(7).ToString().Replace(".", ","))
m4 = CDec("0" & dt.Rows(i)(6).ToString().Replace(".", ","))
m3 = CDec("0" & dt.Rows(i)(5).ToString().Replace(".", ","))
m2 = CDec("0" & dt.Rows(i)(4).ToString().Replace(".", ","))
m1 = CDec("0" & dt.Rows(i)(3).ToString().Replace(".", ","))
p = CDec("0" & dt.Rows(i)(2).ToString().Replace(".", ","))
If p > 0 Then
objid = CInt("0" & dt.Rows(i)(0))
name = dt.Rows(i)(1).ToString().Trim()
If objid = 0 Then
objid = ctl.findCostId(name)
End If
If objid > 0 Then
ctl.ImportToSQL2(_depid, _catid, Year, objid, name, p, m1 / p, m2 / p, m3 / p, m4 / p, m5 / p, m6 / p, m7 / p, m8 / p, m9 / p, m10 / p, m11 / p, m12 / p, UserId)
count += 1
End If
End If
Next
我确定代码没有失败。为什么当我从excel读取并插入或更新到db时,有些行还没有插入或更新到db呢?
我在本地主机上运行是好的,但在服务器上是不是真的?
I sure code isn't fail. why when i read from excel and insert or update to db, some rows not insert or update to db yet?
I run in local host is OK, but on server is not true?
推荐答案
If p > 0 Then
和
and
If objid > 0 Then
ctl.ImportToSQL2(...)
如果 p
不大于0,或者如果找不到 objid
- 对于有理由 - 你的代码没有被执行。
If p
is not greater than 0, or if that objid
was not found - for which ever reason - your code for updating the database is not executed.
这篇关于更新数据库不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!