Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21237

Problem in update database

$
0
0
Hi to all:

This part of code, is suppose write in a DB Access, but something is wrong once the code not work very well, hi mean sometimes the values are stored in DB, sometimes no! Strange no? Yes very strange!!!
Can anyone tell me if i have something wrong in the code that could make this happen? i think the problem is on the code marked on bold!

Thanks


Code:

Private Sub colocarregisto()

Set db = Workspaces(0).OpenDatabase(caminho)
aSQL = "Select * from feiraaves" & ano
aSQL = aSQL & " ORDER BY registo"
Set rsfeiraaves = db.OpenRecordset(aSQL)
Set Data2.Recordset = rsfeiraaves

Do While Not Data2.Recordset.EOF


For n = 1 To 16

s1 = "gaiolaind" & n
s2 = "ano" & n
s3 = "precovenda" & n
s4 = "anilha" & n
s5 = "talao" & n
s6 = "vendido" & n
table = "feiraaves" & ano

If (Data2.Recordset![nomesocio] = Text1(3).Text) And _
(Data2.Recordset.Fields(s1).Value = Text1(2).Text) And _
(Data2.Recordset.Fields(s3).Value = Text1(5).Text) Then
Value = LCase(Text1(1).Text)
Value1 = LCase(Text1(2).Text)
Value2 = LCase(Text1(9).Text)
Sql = "update " & table & " set " & s5 & " = '" & Value & "' where " & s1 & " = '" & Value1 & "'"
db.Execute Sql
Sql = "update " & table & " set " & s6 & " = '" & Value2 & "' where " & s1 & " = '" & Value1 & "'"
db.Execute Sql


Next

Data2.Recordset.MoveNext
Loop



End Sub


Viewing all articles
Browse latest Browse all 21237

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>