R
ravinookala
I am trying to load the values from spread sheet to oracle database
table. my code is doing only the first row five times insted of 5
rows. please help me to inset the next active cell of the range of
values
spread sheet values
===============
empno ename
1 anu
2 niru
3 poonam
4 sahil
5 raju
vb editor code.
===========
Dim CN As New ADODB.Connection
Dim RS As New ADODB.Recordset
Dim i As Integer
Private Sub cmdLoad_Click()
CN.Open "DsnRavi1", "system", "manager"
RS.Open "select * from c", CN, adOpenKeyset, adLockOptimistic
ActiveWorkbook.Sheets("Sheet1").Activate
Range("A2").Select
v_rowcount = Range("A2").CurrentRegion.Rows.Count - 1
For i = 1 To v_rowcount
RS.AddNew
RS!empno = ActiveCell.Value
RS!ename = ActiveCell.Offset(0, 1)
RS.Update
Next i
If IsEmpty(ActiveCell) = True Then
RS.Close
End If
End Sub
table. my code is doing only the first row five times insted of 5
rows. please help me to inset the next active cell of the range of
values
spread sheet values
===============
empno ename
1 anu
2 niru
3 poonam
4 sahil
5 raju
vb editor code.
===========
Dim CN As New ADODB.Connection
Dim RS As New ADODB.Recordset
Dim i As Integer
Private Sub cmdLoad_Click()
CN.Open "DsnRavi1", "system", "manager"
RS.Open "select * from c", CN, adOpenKeyset, adLockOptimistic
ActiveWorkbook.Sheets("Sheet1").Activate
Range("A2").Select
v_rowcount = Range("A2").CurrentRegion.Rows.Count - 1
For i = 1 To v_rowcount
RS.AddNew
RS!empno = ActiveCell.Value
RS!ename = ActiveCell.Offset(0, 1)
RS.Update
Next i
If IsEmpty(ActiveCell) = True Then
RS.Close
End If
End Sub