Google Answers Logo
View Question
 
Q: VB6 code for SQL server export data to Access table ( No Answer,   1 Comment )
Question  
Subject: VB6 code for SQL server export data to Access table
Category: Computers > Programming
Asked by: jstm-ga
List Price: $20.00
Posted: 04 Mar 2005 20:38 PST
Expires: 07 Mar 2005 03:20 PST
Question ID: 484976
I am seeking code for Visual Basic 6 that can pull data from inside
SQL server (table) and put into Microsoft Access (table) automatically
with click of button on VB6 form?

I am very new at programming so please give me step by step
instructions and assume I don't know anything much. Thanks for your
help!!!
Answer  
There is no answer at this time.

Comments  
Subject: Re: VB6 code for SQL server export data to Access table
From: pramod_sharma_sql-ga on 05 Mar 2005 06:00 PST
 
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

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy