Solved

Copy Records from Access To Sybase Using VB6

Posted on 2000-04-07
10
154 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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
 
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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

770 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