PDA

View Full Version : Help me on this issue....



srinimeist86
08-03-2011, 05:30 AM
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 me on this issue

Bob Phillips
08-03-2011, 06:23 AM
Can you post the two workbooks for us to try it with?

srinimeist86
08-03-2011, 10:17 AM
I cant do that...It is confidential file..

If i try with sample information it works fine.
If i try with huge data.it strucks to print the info..
I changed the Format property to General,Text,Number etc...But it is not working...