Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Copy Records from Access To Sybase Using VB6

Posted on 2000-04-07
10
Medium Priority
?
159 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…
Suggested Courses

618 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