VistaDB does not support operations spanning more than one database and there is no supported syntax for specifying it.
However, it's not too hard to do this sort of simple bridging from .NET code using two separate connections. You can find sample source code for a general ADO.NET table (or database) copy program on the Internet on sites like Code Plex, Code Project, and so on. (Usually in C#, but you can also find a code translator to convert it into Visual Basic.)
But the basic outline for copying a single table between databases would be:
Thanks for the reply. I was able to get this to work using the following code in case anyone else would like to perform this operation in vb.net First I loaded a backup vistadb.vdb6 database file name containing the data I wanted to get records from in a treelist control. When you select the Vistadb.vdb6 backup (There could be more than 1) The program displays a list of tables to get records from (Other code logic). Selecting the table in a listbox control, displays the records in that table in another treelist control. Choosing a record in the treelist control loads the record number in another listbox control which are the records that are copied to the master database. vdb6. Below is an example getting data from the client's table. I hope this helps someone else trying to achieve the same thing.
Private Sub TransferClient() Dim MyFile As String = TreeListTransfer.FocusedNode(0).ToString Dim VdbConn1 As String = "Data Source=" & Application.StartupPath & "\Backup\" & MyFile & ".vdb6" Try 'Count the files in the Listbox For i As Integer = 0 To LstFiles.Items.Count - 1 LstFiles.SelectedIndex = i FileId = CInt(LstFiles.Text) 'Add the Contents to the Database Using conn As New VistaDBConnection(VdbConn) conn.Open() StrSql = "INSERT INTO Clients(ClientType, Name, Address, City, State, Zip, Phone, CellPhone, Fax, Email, Web, Since, ClientImage) SELECT ClientType, Name, Address, City, State, Zip, Phone, CellPhone, Fax, Email, Web, Since, ClientImage FROM dbo.Clients WHERE (ClientId = @ClientId)" Using cmd As New VistaDBCommand(StrSql, conn) With cmd.Parameters .AddWithValue("@ClientId", FileId) End With 'Execute the Statement cmd.ExecuteNonQuery() 'Close the Connection conn.Close() End Using End Using Next MessageBox.Show("Transfer successfully completed on the 'Clients' table", "Transfer Client Data", MessageBoxButtons.OK, MessageBoxIcon.Information) Catch ex As Exception MessageBox.Show(ex.Message, "Transfer Client Error", MessageBoxButtons.OK, MessageBoxIcon.Error) Return Finally End Try End Sub
Robert Dunham
Hi,
I have two Vistadb Databases (I'm using Version 6.3.2). One is Database1 and the other is Backup1. Both databases have the same tables and fields. I want to copy records from Backup1 (Clients Table) to Database1 (Clients Table) I'm not sure if I need two different connections for this. Here is what I have so far.
I would sure appreciate help on this.
Thanks,
Robert