Solved

Copy Records from Access To Sybase Using VB6

Posted on 2000-04-07
10
152 Views
Last Modified: 2012-06-21
Hello
I need to copy records from a Local Access DB to Sybase using VB as the tool.
I then as I move the records need to delete them .


I have included some of the fields below


Thanks in advance

Aidan


OrderDate,"
sSql4 = sSql4 & "CreatedAgentID,"
sSql4 = sSql4 & "CreatedDate,"
sSql4 = sSql4 & "ArticleNum,"
sSql4 = sSql4 & "ArticleNum2,"
sSql4 = sSql4 & "ArticleNum3,"
sSql4 = sSql4 & "ArticleNum4,"
sSql4 = sSql4 & "ParkDate,"
sSql4 = sSql4 & "ParkDate2,"
0
Comment
Question by:aidan_gill
  • 6
  • 3
10 Comments
 
LVL 2

Expert Comment

by:damienm
ID: 2692780
Why don't you just use the export function in access to copy to SYBASE
0
 
LVL 2

Author Comment

by:aidan_gill
ID: 2692927
I need to use VB to update Sybase.
0
 
LVL 2

Author Comment

by:aidan_gill
ID: 2692997
I need to use VB to update Sybase.
0
 
LVL 4

Expert Comment

by:gcs001
ID: 2693179
Hi Aidan,
I would advise first copying all the records from the Access tables to your Sybase DB before deleting them from the Access database.  This way if something goes wrong you can easily restart.

you can delete the records from the Access database once all the data has been successfully copied across as a second step, although I'm not sure why you'd want to delete the Access records - keep it as a backup somewhere.

I'll try to find some code that may assist you.
Remember that ADO would be the best way to go.

Regards,
Grant.
0
 
LVL 2

Author Comment

by:aidan_gill
ID: 2693721
I will explain.

If the sybase DB goes down, then it writes to the local, if sybase comes up then it writes from the local to the Sybase, what happens then VB will autorun and copy the records from Access to Sybase.

I would prefer ADO but anything now will do

thanks
Aidan
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 2

Expert Comment

by:damienm
ID: 2699499
You need 3 statements

"select * from accesstableName where...."

while not rs.eof
  "insert into SYBSASETableName fieldName1,fieldName2..) values ('"  & rs!Accessfield1 & "','" & rs!accessfield2 ....

  "delete accesstableName where idVal = " & rs!idField

  rs.movenext
Wend

You can use 2 ODBC connections to connect to the 2 databases
0
 
LVL 2

Author Comment

by:aidan_gill
ID: 2700244
Damien

I am sorry about this but I cannot get ADO to connect to sybase, I had talk around and it seems to be a general problem.

Could you give me the whole example in DAO, I will gladly increase the points.

Rgds
Aidan
0
 
LVL 2

Accepted Solution

by:
damienm earned 50 total points
ID: 2700334
I think that the only problem you have really is connecting to sybase using ADO.

To use ADO you must add Microsoft ActiveX Data Objects 2.1 Library to your list of references.

i.e. Toolbar Project/References.

After that use

Dim rs As New ADODB.Recordset

rs.open "select * from YourtableName","DSN=YourDatabaseName;UID=YourUserId;PWD=YourPassword", adOpenForwardOnly, adLockReadOnly, adCmdText

msgbox rs("AnyfieldName")

if you get a value then you have been able to connect ok.

Otherwise are you sure your ODBC setting are correct.  That you have permissions etc.
0
 
LVL 2

Author Comment

by:aidan_gill
ID: 2700455
Damien.

I have everything connected, I also have the ODBC's correct.
I can connect to access and SQL Server using the same sort of code(changed the DSN etc) but no go, I can write to the Sybase DB using DAO, but do not have the knowledge to write from Access and read to Syabase in one go

Thanks
AIdan
0
 
LVL 2

Author Comment

by:aidan_gill
ID: 2787756
thanks Damien
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now