Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: transfer access tables to sybase server ver ion 11 via visual basic (access macro code)


Message #1 by "Elizabeth Ong" <eong@n...> on Thu, 10 Aug 2000 18:53:34
Would this be the same as exporting an access table to Sybase server ?...
You need to use a database object and a tabledef object.

How does this 'TransferDatabase' syntax should be when in visual basic and
you need to export from access to sybase ?

I would appreciate very much if you could let me know the proper way as I've
spend hours already trying to find out what is wrong ?

Thanks,

Elizabeth

> -----Original Message-----
> From:	Godfroy Touglo [SMTP:GodfroyT@n...]
> Sent:	Thursday, August 10, 2000 3:01 PM
> To:	professional vb
> Subject:	[pro_vb] RE: transfer access tables to sybase server ver ion
> 11 v	ia visual basic (access macro code)
> 
> Of course this will not work if you are in VB because the database object
> is
> not set(as stated in the error message). This syntax works only in Access
> because you would be in the database to run this macro.
> Any way,  If you want to do the same thing in VB you have to use a
> Database
> and a Tabledef object. Set the databse object to the Access DB, then
> create
> the tabledef object and after you've set the Connect and SourceTableName
> properties, add the tabledef to the tabledefs collection. That's all you
> need to do. Here's a little code to test what I said. Put the code in a
> Sub
> procedure. Make sure you replace db1.mdb with the name of your Access DB,
> replace anything in <> with your parameters. I hope this helps.
> 
> '===== Code begins ===============
> Dim myDB As Database
> Dim sCon As String
> Dim sTableToLink As String
> Dim sLinkedName As String
> Dim tdfLinked As TableDef
> 
>     'Open the DB    
>     Set myDB = dbengine.opendatabase("c:\db1.mdb")
>     sCon = "ODBC;Database=<your DB>;SRVR=<your server>;UID=<your user
> id>;PWD=<your password>;DSN=<your DSN>"
> 
>     sLinkedName="table1"
>     Set tdfLinked = myDB.CreateTableDef(sLinkedName)
> 
>     'Set the connection 	
>     tdfLinked.Connect = sCon
> 
>     'set the source table name	
>     tdfLinked.SourceTableName = strTableToLink
> 
>     'Append the tabledef object to the tabledefs colletions
>     myDB.TableDefs.Append tdfLinked
> '======== Code ends
> 

  Return to Index