Private Sub Command1_Click()
str1 = "select * from consumer_master"
Adodc1.RecordSource = str1
Adodc1.Refresh
'Adodc2 = Adodc1.RecordSource
str2 = "insert into table (cash_coll,DIV_SUBDIV,ACCOUNT_NO,CY," & _
"GP,SUBGP,BILL_TYPE,NAME,ADDRESS,ELEC_SOP,ELEC_ED,ELEC_TOT,
ELEC_SURCH, ELEC_GROSS,CESS_W," & _
"WAT_TOT,WAT_SURCH,WAT_GROSS,TOTAL_NET,TOTAL_SURCH, " & _
"TOTAL_GROSS, TARRIF_E, TARRIF_W, DUE_DT_CASH, DUE_DT_CHEQUE," & _
" ENTERED_BY , ENTERED_DATE_TIME, MODIFIED_BY, MODIFIED_DATE_TIME,
TERMINAL_NAME_ADD, TERMINAL_NAME_MODIFY, Status) values ("
'str5 = "!" & cash_coll & " , !" & DIV_SUBDIV & " , !" & ACCOUNT_NO & " , !" & CY
'str6 = ",!" & GP & " ,! " & SUBGP & " , !"
'str7 = BILL_TYPE & " ,! " & Name & " , !" & ADDRESS & " ,! " &
ELEC_SOP & " ,!" & ELEC_ED & " ,!"
' str8 = ELEC_TOT & " ,!" & ELEC_SURCH & " , !" & ELEC_GROSS & " , !"
& CESS_W & " , !" & WAT_TOT & " , !" & WAT_SURCH & " ,!" & WAT_GROSS &
" , !" & TOTAL_NET & " , !"
'str9 = TOTAL_SURCH & " , !" & TOTAL_GROSS & " , !" & TARRIF_E & " ,
!" & TARRIF_W & " , !" & DUE_DT_CASH & " , !" & DUE_DT_CHEQUE & " , "
'str10 = "'ADMIN'" & " , " & Date & ",,,'ESAMPARK',,'N')"
'str4 = str2 + str5 + str6 + str7 + str8 + str9 + str10
conn.Open ("Provider=MSDAORA.1;Password=88888;User ID=88888;Data
Source=88888;Persist Security Info=True")
rno = Adodc1.Recordset.RecordCount
r = 1
With Adodc1.Recordset
.MoveFirst
Do While r <= rno
str5 = !cash_coll & " ," & !DIV_SUBDIV & " ,'" & !ACCOUNT_NO & "' , " & !CY
str6 = "," & !GP & " , " & !SUBGP & " , '"
str7 = !BILL_TYPE & "' , '" & !Name & "' ,'" & !ADDRESS & "' , " &
!ELEC_SOP & " ," & !ELEC_ED & " ,"
str8 = !ELEC_TOT & " ," & !ELEC_SURCH & " , " & !ELEC_GROSS & " , " &
!CESS_W & " , " & !WAT_TOT & " , " & !WAT_SURCH & " ," & !WAT_GROSS &
" , " & !TOTAL_NET & " , "
str9 = !TOTAL_SURCH & " , " & !TOTAL_GROSS & " , "
str10 = (!TARIff_e) & " ," & Val(!TARIfF_W)
str11 = " , to_date('" & !DUE_DT_CASH & "','dd/mm/yyyy') ,to_date('" &
!DUE_DT_CHEQUE & "','dd/mm/yyyy') , "
str12 = "'ADMIN'" & " , to_date('" & Date & "','dd/mm/yyyy'),'
',null,'ESAMPARK',' ','N')"
Str4 = str2 + str5 + str6 + str7 + str8 + str9 + str10 + str11 + str12
conn.Execute Str4, sss
'Adodc2.RecordSource = Str4
'On Error Resume Next
'Adodc2.Refresh
.MoveNext
pb1.Value = r
r = r + 1
Loop
End With
'Adodc2.RecordSource = "select * from new_table"
'On Error Resume Next
'Adodc2.Refresh
MsgBox r - 1 & " Records Imported Sucessfully", vbOKOnly
End Sub
this is used for exporting from access to sql
just change the ado
hope this helped u
pramod
bye |