Last post Aug 10, 2013 03:30 AM by raj1947
Aug 06, 2013 12:41 AM|raj1947|LINK
I need to transfer the older access.mdb file to newly create access.mdb some addtion fields are add in newly create mdb file by using C#.net its very aurgent.
Aug 06, 2013 12:48 AM|ramu.net|LINK
You would just need to make a Jet or ADO connection to the other database, and then create a recordset that either updates or inserts your data.
How are you packaging the data that is going to be sent to the other database? Where is the other database? Is it on your LAN? If so, how many database instances will be sending data to the other database (just you, or 100 other users?) Also, will the receiving
database be used for transactions in real time other than the ones you are sending? Will you use a DSN?
If you were using a form, for example, and sending a user's first and last names, identifying the record with a PK that was the same in both databases, your code would look something like:
Dim lPK As Long
Dim sLast As String
Dim sFirst As String
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sSQL As String
lPK = Me.ID
sLast = Me.LastName
sFirst = Me.FirstName
sSQL = "UPDATE tblMyOtherDatabaseTable " & _
"SET [LastName] = '" & sLast & "', " & _
"[FirstName] = '" & sFirst & "' " & _
"WHERE ID = " & lPK
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=\my_path\MyOtherDatabase.mdb;" & _
"User ID=userid;" & _
Set rs = New ADODB.Recordset
rs.Open sSQL, cn, adOpenDynamic, adLockOptimistic
'the act of opening the recordset using the connection object updates the database.
So something like this would work. You can also use a DSN and lose some of the connection string.
Refer below links
I hope these will help you.
Aug 06, 2013 01:44 AM|raj1947|LINK
I need to to transfer the entire data from one table to another Empty table using the ADO connection
Aug 06, 2013 04:55 AM|hans_v|LINK
your code would look something like:
You're showing classic ASP (Vb script)!
Aug 06, 2013 05:13 AM|hans_v|LINK
When you've Access, then you could easliy do this by linking the table in the second database into the first database., and then you can use both tables just like they are inside the same database.
In code, you can link them also, but you don't need to. When the structure of both tables is exactly the same, create a connection with the "New" database, and then execute this:
INSERT INTO [YourNewTable] SELECT * FROM [MS Access;DATABASE=D:\Path\To\OldDatabase.mdb].[YourOldTable]
If the structure is not the same:
INSERT INTO [YourNewTable] (field1, field2, field3) SELECT field1, field2, field3 FROM [MS Access;DATABASE=D:\Path\To\OldDatabase.mdb].[YourOldTable]
Aug 09, 2013 08:26 AM|raj1947|LINK
I have tried the above code but am having error during run the program as (Invalid argument. and error code -2147467259 )
and i showed my code below
string conString = @"Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=G:\CabinetPorting\CabinetPorting\New Database\CabinetDB.mdb;Jet OLEDB:Database Password=pslCAB";
OleDbConnection dbconn = new OleDbConnection(conString);
OleDbDataAdapter dAdapter = new OleDbDataAdapter();
OleDbCommand dbcommand = new OleDbCommand();
if (dbconn.State == ConnectionState.Closed)
//string selQuery = "INSERT INTO [Drawer] SELECT * FROM [MS Access;DATABASE=" +
// "\\CabinetDB.mdb" + "; Jet OLEDB:Database Password=pslCAB;].[Drawer]";
string selQuery = "INSERT INTO [Drawer](Draw_Code,Draw_Name,Cab_Code,Remarks,Delflag,Reference1,Reference2,Reference3,Reference4) SELECT Draw_Code,Draw_Name,Cab_Code,Remarks,Delflag,Reference1,Reference2,Reference3,Reference4 FROM [MS Access;DATABASE=Provider=Microsoft.Jet.OLEDB.4.0
;Data Source=G:\\CabinetPorting\\CabinetPorting\\old Database\\CabinetDB.mdb;Jet OLEDB:Database Password=pslCAB;].[Drawer]";
dbcommand.CommandText = selQuery;
dbcommand.CommandType = CommandType.Text;
dbcommand.Connection = dbconn;
int result = dbcommand.ExecuteNonQuery();
catch (InvalidCastException r)
plz replay me..its urgent
Aug 09, 2013 11:17 AM|hans_v|LINK
I have tried the above code
But you changed the syntax. When the Database is protected with a password, you need to add the PWD argument:
string selQuery = "INSERT INTO [Drawer](Draw_Code,Draw_Name,Cab_Code,Remarks,Delflag,Reference1,Reference2,Reference3,Reference4) SELECT Draw_Code,Draw_Name,Cab_Code,Remarks,Delflag,Reference1,Reference2,Reference3,Reference4 FROM [MS Access;DATABASE=G:\CabinetPorting\CabinetPorting\old Database\CabinetDB.mdb;PWD=pslCAB].[Drawer]";
Aug 10, 2013 03:30 AM|raj1947|LINK
Thank Dude.. Its working fine.....