473,408 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Copy Table from One computer to another in network.

115 100+
i'm using VB.NET

i have 4 computers in network.
when i press a button i need to delete a table from computer 2,3,4 and i need to copy that table from computer 1 to 2,3,4.
and this file is a table inside a .mdb file. so i can't use "FILECOPY(sOURCE,DESTINATION)".

Eg: if the path is "c:\Programs\data.mdb" ,then Emp is one of the table inside that data.mdb. and i don't need to delete entire data.mdb, i need to delete only that "Emp" table and i don't need to copy entire data.mdb, i need to copy only "Emp" table and save it in computers 2,3,4.

if anyone have anyidea how to delete and copy this table inside .mdb file, to other computers in network.

if you have any idea please let me know. and if you can provide eg: that will be great help for me.

thanks in advance.
Sep 14 '07 #1
4 1523
remya1000
115 100+
i tried this code....

Code
--------
Dim nPath As String = "\\t1\root\Programs"
Dim strConn1 As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & nPath & "\DataTables.mdb"


Dim strSQL1 As String = "Select * from Employees"
Dim myConnection1 As New OleDbConnection(strConn1)
myConnection1.Open()
Dim myCommand1 As New OleDbCommand(strSQL1, myConnection1)
Dim myReader1 As OleDbDataReader = myCommand1.ExecuteReader

While myReader1.Read
Dim nPath2 As String = "\\t2\root\Programs"
Dim strConn2 As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & nPath2 & "\Terminal.mdb"

Dim strSQL2 As String = "insert into Employees (EmpID, FirstName, LastName, AccessN0,CardNo,InsuranceNo) values (" & Trim(myReader1(0)) & ", '" & Trim(myReader1(1)) & "', '" & Trim(myReader1(2)) & "', " & Trim(myReader1(3)) & ", " & Trim(myReader1(4)) & ", " & Trim(myReader1(5)) & ", " & Trim(myReader1(6)) & ") "
Dim myConnection2 As New OleDbConnection(strConn2)
myConnection2.Open()
Dim myCommand2 As New OleDbCommand(strSQL2, myConnection2)
myCommand2.ExecuteNonQuery()
End While

myReader1.Close()
myConnection1.Close()
Sometimes some of the fields will be blank. and while trying to insert the values to computer 2 from computer 1 error occurs as

Error:
------
"An unhandled exception of type 'System.InvalidCastException' occurred in microsoft.visualbasic.dll. Additional information: Cast from type 'DBNull' to type 'String' is not valid."

if anyone have anyidea what's wrong in my codes please help me.

thanks in advance.
Sep 17 '07 #2
remya1000
115 100+
Code:

Dim nPath As String = "\\t1\root\Programs"
Dim strConn1 As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & nPath & "\DataTables.mdb"

Dim strSQL1 As String = "Select * from Emp"
Dim myConnection1 As New OleDbConnection(strConn1)
myConnection1.Open()
Dim myCommand1 As New OleDbCommand(strSQL1, myConnection1)
Dim myReader1 As OleDbDataReader = myCommand1.ExecuteReader

While myReader1.Read
Dim nPath2 As String = "t2\\root\Programs"
Dim strConn2 As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & nPath2 & "\DataTable.mdb"

Dim strSQL2 As String = "insert into Emp (EmployeeID, EmployeePrivateAccessNumber,SwipeCardNumber,Social InsuranceNumber, FirstName, LastName, Title, Address, City, State, PostalCode, HomePhone, EmrgcyContactName, EmrgcyContactPhone, IsThisPersonAManager, OpenWhichCashDrawer, AccessToManagerScreen, AllowedToGiveDiscounts, AllowedToDeleteSentItems, AllowedToCompItems, AllowedToCashOut, AllowedToAccessOtherOrders, AllowedToChangeItems, AllowedToRunReports, AllowedToQuickCashOut, WhichMenuLevel, index, StartOnQuickScreen, HourlyWage, AllowedToTransferOrders, Dancer, StageName, Age, DepartmentID, ListStyle, AccessToServerSide, Driver, AccessToPrintSpooler, BusBoy, WhichRoom, AccessToHouseAccounts, ShareTips, JobCode1, JobCode2, JobCode3, JobCode4, JobCode5, JobCode6, JobCode7, JobCode8, JobCode9, JobCode10, JobCode1HourlyWage, JobCode2HourlyWage, JobCode3HourlyWage, JobCode4HourlyWage, JobCode5HourlyWage, JobCode6HourlyWage, JobCode7HourlyWage, JobCode8HourlyWage, JobCode9HourlyWage, JobCode10HourlyWage, Message, Cashier, TipOutToBarStaffOnLogOut, TipOutToKitchenStaffOnLogOut, AllowedToEmail, MultiSelectOnMainMenuList, RecordLogOutInfo, TrainingMode, InActive, Salaried, DeliveryDispatcher, ForceDrawer1_2, JobCodeProfile, CompValue, CashLimit, ServerKey, ClearviewKey, LanguagePreference, AccessLevel) " & _
"values ('" & CheckNull(Trim(myReader1(0))) & "', '" & CheckNull(Trim(myReader1(1))) & "', '" & Trim(myReader1(2)) & "', '" & CheckNull(Trim(myReader1(3))) & "', '" & CheckNull(Trim(myReader1(4))) & "', '" & CheckNull(Trim(myReader1(5))) & "', '" & CheckNull(Trim(myReader1(6))) & "', '" & CheckNull(Trim(myReader1(7))) & "', '" & CheckNull(Trim(myReader1(8))) & "', '" & CheckNull(Trim(myReader1(9))) & "', '" & CheckNull(Trim(myReader1(10))) & "', '" & CheckNull(Trim(myReader1(11))) & "', '" & CheckNull(Trim(myReader1(12))) & "', '" & CheckNull(Trim(myReader1(13))) & "', '" & CheckNull(Trim(myReader1(14))) & "', '" & CheckNull(Trim(myReader1(15))) & "', '" & CheckNull(Trim(myReader1(16))) & "', '" & CheckNull(Trim(myReader1(17))) & "', '" & CheckNull(Trim(myReader1(18))) & "', '" & CheckNull(Trim(myReader1(19))) & "', '" & CheckNull(Trim(myReader1(20))) & "', '" & CheckNull(Trim(myReader1(21))) & "', '" & CheckNull(Trim(myReader1(22))) & "', '" & CheckNull(Trim(myReader1(23))) & "', '" & CheckNull(Trim(myReader1(24))) & "', '" & CheckNull(Trim(myReader1(25))) & "', '" & CheckNull(Trim(myReader1(26))) & "', '" & CheckNull(Trim(myReader1(27))) & "', '" & CheckNull(Trim(myReader1(28))) & "', '" & CheckNull(Trim(myReader1(29))) & "', '" & CheckNull(Trim(myReader1(30))) & "', '" & CheckNull(Trim(myReader1(31))) & "', '" & CheckNull(Trim(myReader1(32))) & "', '" & CheckNull(Trim(myReader1(33))) & "', '" & CheckNull(Trim(myReader1(34))) & "', '" & CheckNull(Trim(myReader1(35))) & "', '" & CheckNull(Trim(myReader1(36))) & "', '" & CheckNull(Trim(myReader1(37))) & "', '" & CheckNull(Trim(myReader1(38))) & "', '" & CheckNull(Trim(myReader1(39))) & "', '" & CheckNull(Trim(myReader1(40))) & "', '" & CheckNull(Trim(myReader1(41))) & "', '" & CheckNull(Trim(myReader1(42))) & "', '" & CheckNull(Trim(myReader1(44))) & "', '" & CheckNull(Trim(myReader1(45))) & "', '" & CheckNull(Trim(myReader1(46))) & "', '" & CheckNull(Trim(myReader1(47))) & "', '" & CheckNull(Trim(myReader1(48))) & "', '" & CheckNull(Trim(myReader1(49))) & "', '" & CheckNull(Trim(myReader1(51))) & "', '" & CheckNull(Trim(myReader1(52))) & "', '" & CheckNull(Trim(myReader1(53))) & "', '" & CheckNull(Trim(myReader1(54))) & "', '" & CheckNull(Trim(myReader1(55))) & "', '" & CheckNull(Trim(myReader1(56))) & "', '" & CheckNull(Trim(myReader1(57))) & "', '" & CheckNull(Trim(myReader1(58))) & "', '" & CheckNull(Trim(myReader1(59))) & "', '" & CheckNull(Trim(myReader1(60))) & "', '" & CheckNull(Trim(myReader1(61))) & "', '" & CheckNull(Trim(myReader1(62))) & "', '" & CheckNull(Trim(myReader1(62))) & "', '" & CheckNull(Trim(myReader1(63))) & "', '" & CheckNull(Trim(myReader1(64))) & "', '" & CheckNull(Trim(myReader1(65))) & "', '" & CheckNull(Trim(myReader1(66))) & "', '" & CheckNull(Trim(myReader1(67))) & "', '" & CheckNull(Trim(myReader1(68))) & "', '" & CheckNull(Trim(myReader1(69))) & "', '" & CheckNull(Trim(myReader1(70))) & "', '" & CheckNull(Trim(myReader1(71))) & "', '" & CheckNull(Trim(myReader1(72))) & "', '" & CheckNull(Trim(myReader1(73))) & "', '" & CheckNull(Trim(myReader1(74))) & "', '" & CheckNull(Trim(myReader1(75))) & "', '" & CheckNull(Trim(myReader1(76))) & "', '" & CheckNull(Trim(myReader1(77))) & "', '" & CheckNull(Trim(myReader1(78))) & "', '" & CheckNull(Trim(myReader1(79))) & "', '" & CheckNull(Trim(myReader1(80))) & "') "

Dim myConnection2 As New OleDbConnection(strConn2)
myConnection2.Open()
Dim myCommand2 As New OleDbCommand(strSQL2, myConnection2)
myCommand2.ExecuteNonQuery()
End While

myReader1.Close()
myConnection1.Close()
myCommand1.Dispose()


Public Function CheckNull(ByVal Value As String) As String
If IsDBNull(Value) Then
Return ("")
ElseIf Value = "." Then
Return ("")
ElseIf Value = "" Then
Return ("")
Else
Return CStr(Value)
End If
End Function
and while running its passing through SQL. and that its taking vlues too. and i'm pasting that SQL taking values during run time here.

"insert into Emp (EmployeeID, EAccessNumber, ........etc) values (4192, 9, 112, ., 'Manager', 'Manager', '.', '.', '.', '.', '.', '.', '.', '.', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 78, 0, 0, 1, '0', ., 0, 1, 0, 0, 0, 0, 0, 302, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ., '.', 0, 0, 0, 1, 1, 2, 0, 0, 0, 0, 1, 0, 0, 0, 4, 300101, 0, 0) "

and when it reach this myCommand2.ExecuteNonQuery() line error occurs as below.
Error
-----
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll

if anyone have anyidea what's the mistake i did in my codes, please let me know. please help me...

thanks in advance...
Sep 17 '07 #3
remya1000
115 100+
and i insert the TRy Catch in my codes.


Code:
Dim nPath As String = "\\t1\root\Programs"
Dim strConn1 As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & nPath & "\DataTables.mdb"

Dim strSQL1 As String = "Select * from Emp"
Dim myConnection1 As New OleDbConnection(strConn1)
myConnection1.Open()
Dim myCommand1 As New OleDbCommand(strSQL1, myConnection1)
Dim myReader1 As OleDbDataReader = myCommand1.ExecuteReader

While myReader1.Read
Dim nPath2 As String = "t2\\root\Programs"
Dim strConn2 As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & nPath2 & "\DataTable.mdb"

Try
Dim strSQL2 As String = "insert into Emp (EmployeeID, EmployeePrivateAccessNumber,SwipeCardNumber,Social InsuranceNumber, FirstName, LastName, Title, Address, City, State, PostalCode, HomePhone, EmrgcyContactName, EmrgcyContactPhone, IsThisPersonAManager,OpenWhichCashDrawer, AccessToManagerScreen, AllowedToGiveDiscounts, AllowedToDeleteSentItems, AllowedToCompItems, AllowedToCashOut, AllowedToAccessOtherOrders, AllowedToChangeItems, AllowedToRunReports, AllowedToQuickCashOut, WhichMenuLevel, StartOnQuickScreen, HourlyWage, AllowedToTransferOrders, Dancer, StageName, Age, DepartmentID, ListStyle, AccessToServerSide, Driver, AccessToPrintSpooler, BusBoy, WhichRoom, AccessToHouseAccounts, ShareTips, JobCode1, JobCode2, JobCode3, JobCode4, JobCode5, JobCode6, JobCode7, JobCode8, JobCode9, JobCode10, JobCode1HourlyWage, JobCode2HourlyWage, JobCode3HourlyWage, JobCode4HourlyWage, JobCode5HourlyWage, JobCode6HourlyWage, JobCode7HourlyWage, JobCode8HourlyWage, JobCode9HourlyWage, JobCode10HourlyWage, Message, Cashier, TipOutToBarStaffOnLogOut, TipOutToKitchenStaffOnLogOut, AllowedToEmail, MultiSelectOnMainMenuList, RecordLogOutInfo, TrainingMode, InActive, Salaried, DeliveryDispatcher, ForceDrawer1_2, JobCodeProfile, CompValue, CashLimit, ServerKey, ClearviewKey, LanguagePreference, AccessLevel) " & _
"values (" & EmpId & ", " & AccessNo & ", " & Cardno & ", '" & SINno & "', '" & FName & "', '" & LName & "', '" & eTitle & "','" & eAddress & "', '" & eCity & "', '" & eState & "', '" & ePin & "', '" & eHomePhone & "', '" & eEmyContactName & "', '" & eEmyContactPhone & "', " & isManager & ", " & eOpenCashDraw & ", " & ManagerScreen & ", " & GiveDiscount & ", " & delsend & ", " & eCompItem & ", " & eCashOut & ", " & eAccessOrder & ", " & eChangeitems & ", " & eRunReport & ", " & eQuickcashOut & ", " & eMenuLevel & ", " & eQuickscreen & ", " & eHourWage & ", " & eTransferOrder & ", " & eDance & ", '" & eStageName & "', " & eAge & ", " & eDepId & ", " & eListStyle & ", " & eServerSide & ", " & eDriver & ", " & ePrintSpooler & ", " & eBusBoy & ", " & eWhichRoom & ", " & eHouseAccount & ", " & Trim(myReader1(41)) & ", " & Trim(myReader1(42)) & ", " & Trim(myReader1(43)) & ", " & Trim(myReader1(44)) & ", " & Trim(myReader1(45)) & ", " & Trim(myReader1(46)) & ", " & Trim(myReader1(47)) & ", " & Trim(myReader1(48)) & ", " & Trim(myReader1(49)) & ", " & Trim(myReader1(50)) & ", " & Trim(myReader1(51)) & ", " & Trim(myReader1(52)) & ", " & Trim(myReader1(53)) & ", " & Trim(myReader1(54)) & ", " & Trim(myReader1(55)) & ", " & Trim(myReader1(56)) & ", " & Trim(myReader1(57)) & ", " & Trim(myReader1(58)) & ", " & Trim(myReader1(59)) & ", " & Trim(myReader1(60)) & ", " & Trim(myReader1(61)) & ", '" & emessage & "', " & Trim(myReader1(63)) & ", " & Trim(myReader1(64)) & ", " & Trim(myReader1(65)) & ", " & Trim(myReader1(66)) & ", " & Trim(myReader1(67)) & ", " & Trim(myReader1(68)) & ", " & Trim(myReader1(69)) & ", " & Trim(myReader1(70)) & ", " & Trim(myReader1(71)) & ", " & Trim(myReader1(72)) & ", " & Trim(myReader1(73)) & ", " & Trim(myReader1(74)) & ", " & Trim(myReader1(75)) & ", " & Trim(myReader1(76)) & ", " & Trim(myReader1(77)) & ", " & Trim(myReader1(78)) & ", " & Trim(myReader1(79)) & ", " & Trim(myReader1(80)) & ") "
Dim myConnection2 As New OleDbConnection(strConn2)
myConnection2.Open()
Dim myCommand2 As New OleDbCommand(strSQL2, myConnection2)
myCommand2.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(Err.Number & " - " & ex.Message)
End Try

Dim myConnection2 As New OleDbConnection(strConn2)
myConnection2.Open()
Dim myCommand2 As New OleDbCommand(strSQL2, myConnection2)
myCommand2.ExecuteNonQuery()
End While

myReader1.Close()
myConnection1.Close()
myCommand1.Dispose()

sometimes it take values from T1 and writes to T2. sometimes i get this error

"5 - Could not update; currently locked by user 'Admin' on machine 'T2'."


and before showing this error some of the records got saved in mdb. and ecah time the number of records enter in mdb before showing this error is random. sometime all the recorsd will be saved and it won't show this error too.

and database is not open while running the code. and no other calls are made to the database at that time too.

if you have any idea what's wrong in my codes please help me. and please let me know. please help me.

thanks in advance.
Sep 18 '07 #4
remya1000
115 100+
heah its working now......
that error occurs because myConnection2 is opening each time while its enter while loop but its not closing.

Thanks a lot for your help..... thanks a lot.....

Expand|Select|Wrap|Line Numbers
  1. Dim nPath As String = "\\t1\root\Programs"
  2.         Dim strConn1 As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  3.                                        "Data Source=" & nPath & "\DataTables.mdb"
  4.  
  5.         Dim strSQL1 As String = "Select * from Emp"
  6.         Dim myConnection1 As New OleDbConnection(strConn1)
  7.         myConnection1.Open()
  8.         Dim myCommand1 As New OleDbCommand(strSQL1, myConnection1)
  9.         Dim myReader1 As OleDbDataReader = myCommand1.ExecuteReader
  10.  
  11. While myReader1.Read
  12.             Dim nPath2 As String = "t2\\root\Programs"
  13.             Dim strConn2 As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  14.                                            "Data Source=" & nPath2 & "\DataTable.mdb"
  15.  
  16.   Try
  17.                 Dim strSQL2 As String = "insert into Emp (EmployeeID, ...... ) " & _
  18.                                   "values (" & EmpId & ", .....) "
  19.                 Dim myConnection2 As New OleDbConnection(strConn2)
  20.                 myConnection2.Open()
  21.                 Dim myCommand2 As New OleDbCommand(strSQL2, myConnection2)
  22.                 myCommand2.ExecuteNonQuery()
  23.             Catch ex As Exception
  24.                 MessageBox.Show(Err.Number & " - " & ex.Message)
  25.             End Try
  26.  
  27.             Dim myConnection2 As New OleDbConnection(strConn2)
  28.             myConnection2.Open()
  29.             Dim myCommand2 As New OleDbCommand(strSQL2, myConnection2)
  30.             myCommand2.ExecuteNonQuery()
  31.             myConnectio2.Close()
  32.         End While
  33.  
  34.         myReader1.Close()
  35.         myConnection1.Close()
  36.         myCommand1.Dispose()
  37.  
  38.  
  39.  
Sep 19 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Ove | last post by:
I have one Access 2000 DB on my website. I want to access these tables from my local database so i do not need to down-/upload the database each time i want to make changes. Meanwhile i want a...
4
by: GiladP1 | last post by:
Hi, I want to copy protect my application. I want to limit its use for a given period of time, say 30 days, after which a license key will be needed. There are various issues to consider here...
8
by: Ram Baruch | last post by:
Hi, I'm trying to use the File.Copy() function. It works well when the desenation file is local (Like: C:\dest\dest.exe). The problem is that when I'm trying to copy to a destenation that starts...
4
by: adnan boz | last post by:
Hi All, Does somebody know why File.Copy function is 10 times slower than standard windows drag and drop copy between folders, when I copy files over the network? Actually, I need to copy files...
0
by: Paul Brady | last post by:
I volunteer at a youth ministry agency and help them with their student database. They have two computers, both running Windows XP. Both have Office 2002 installed without Access, except that...
3
by: =?Utf-8?B?U2Vhbk1hYw==?= | last post by:
How do I programmatically copy files across a network (from a local workstation to another local workstation on the network) using visual basic 2005? In other words, when in explorer and you enter...
25
by: Andy_Khosravi | last post by:
I just recently changed my database that I'm running from a monolithic DB to a split FE/BE. The front end resides on the client machine and the BE resides on a network drive. I'm experimenting with...
9
rizwan6feb
by: rizwan6feb | last post by:
Hello everybody. I need help on how to use copy function to copy file from one computer to another ( or any other way i can copy the file). The computers are on a local network.
10
by: Jason | last post by:
I want to create a simple program with Two buttons on the form. BUTTON 1 - BACKUP PREFS this will do the following: Copy C:\Documents and Settings\%USERNAME%\Application Data\FileZilla...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.