Link to home
Start Free TrialLog in
Avatar of aidan_gill
aidan_gill

asked on

Copy Records from Access To Sybase Using VB6

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,"
Avatar of damienm
damienm
Flag of United Kingdom of Great Britain and Northern Ireland image

Why don't you just use the export function in access to copy to SYBASE
Avatar of aidan_gill
aidan_gill

ASKER

I need to use VB to update Sybase.
I need to use VB to update Sybase.
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.
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
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
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
ASKER CERTIFIED SOLUTION
Avatar of damienm
damienm
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
thanks Damien