Solved

Copy Records from Access To Sybase Using VB6

Posted on 2000-04-07
10
153 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

867 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

15 Experts available now in Live!

Get 1:1 Help Now