Solved

Copy Records from Access To Sybase Using VB6

Posted on 2000-04-07
10
155 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
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!

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

726 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