srinimeister86
New Member
- Joined
- Aug 3, 2011
- Messages
- 1
hi
I am trying to copy data from one excel sheet to another using ADODB Connection. I am able to fetch the data except one field. Even if it has value it gives me empty string.
set con = new abodb.connection//First excel
set con1 = new abodb.connection//second excel
set rs = new adodb.recordset
set rs1 = new adodb.recordset //second excel
//i declared the connection string
cn.open
cn1.open
squery= "select * from [Sheet1$]"
rs1.open squery,cn1,adlockoptimistic,adopendynamic
rs.open squery,cn,adlockoptimistic,adopendynamic
rs.movefirst
do until rs.EOF
if(IsNull(rs.Fields(2)) = True) then
goto L1
else
rs1.fields(1) = rs.fields(1)
rs1.fields(2) = rs.fields(2)
rs1.fields(3) = rs.fields(3)
rs1.update
rs1.movenext
endif
L1:
rs.movenext
loop
In this case rs.Fields(2) creates the problem. If it does not has any data it return Null value and if it has data in the cell then it return "" empty string value. Kindly help me on this issue. For the rest of the fields i am getting information and for the second field i am getting empty string instead of valid data...help pn this issue
I am trying to copy data from one excel sheet to another using ADODB Connection. I am able to fetch the data except one field. Even if it has value it gives me empty string.
set con = new abodb.connection//First excel
set con1 = new abodb.connection//second excel
set rs = new adodb.recordset
set rs1 = new adodb.recordset //second excel
//i declared the connection string
cn.open
cn1.open
squery= "select * from [Sheet1$]"
rs1.open squery,cn1,adlockoptimistic,adopendynamic
rs.open squery,cn,adlockoptimistic,adopendynamic
rs.movefirst
do until rs.EOF
if(IsNull(rs.Fields(2)) = True) then
goto L1
else
rs1.fields(1) = rs.fields(1)
rs1.fields(2) = rs.fields(2)
rs1.fields(3) = rs.fields(3)
rs1.update
rs1.movenext
endif
L1:
rs.movenext
loop
In this case rs.Fields(2) creates the problem. If it does not has any data it return Null value and if it has data in the cell then it return "" empty string value. Kindly help me on this issue. For the rest of the fields i am getting information and for the second field i am getting empty string instead of valid data...help pn this issue