copying files from one database to another database

srivalli

Well-known member
Joined
May 4, 2005
Messages
189
Programming Experience
Beginner
i am trying to copy foxpro tables or files to sqlserver
and i want to do it using .net program
instead of using import /Export option available in SQL server
thanks
 
Moved to more appropriate forum.

Visit www.connectionstrings.com to get the appropriate connection string for FoxPro. Create a OleDbDataAdapter to retrieve the required data from FoxPro into a DataTable. If there are multiple tables then use multiple data adapters to fill multiple DataTables. If you set the AcceptChangesDuringFill property to False then all the DataRows will have a RowState of Added, which means you can then insert them into SQL Server directly. You can either use SqlClient to connect to SQL Server or use OleDb and use the same data adapters that you used to retrieve the data.
 
qry in transferring

first i created one connection object to connect to foxpro
now i am trying to retrieve one table from foxpro database into my .net form
the data is being displayed in the form
now i am unable to transfer that data into SQL server data base.
i also made AcceptChangesDuringFill property to False

jmcilhinney said:
Moved to more appropriate forum.

Visit www.connectionstrings.com to get the appropriate connection string for FoxPro. Create a OleDbDataAdapter to retrieve the required data from FoxPro into a DataTable. If there are multiple tables then use multiple data adapters to fill multiple DataTables. If you set the AcceptChangesDuringFill property to False then all the DataRows will have a RowState of Added, which means you can then insert them into SQL Server directly. You can either use SqlClient to connect to SQL Server or use OleDb and use the same data adapters that you used to retrieve the data.
 
srivalli said:
i am unable to transfer that data into SQL server data base
Could you be a bit more specific? What are you attempting and what is happening?
 
qry in transferring foxpro to sql server

i am trying to transfer foxpro database tables in sql server database
and i followed the steps as mentioned earlier
ie
using datatable i dumped foxpro file in a datagrid
now i want to transfer that file in a sql server.
in properties i made set acceptfillchange.. property to false
any suggestions
thanks

jmcilhinney said:
Could you be a bit more specific? What are you attempting and what is happening?
 
Here's what you will need to do:
1) Make sure the destination tables exist in the SQL Server.
2) Open a connection to FoxPro
3) Open connection to SQL Server
4) Select the data from FP and put it into a DataSet/DataTable
5) Select from the SQL Server the corresponding table (yes, I know it'll be blank, we're getting the table schema, which is what we really want)
6) For each DataRow in the FP DT.... create a new DataRow for the SQL DT and add it
7) Once done copy the data from one DataTable to the other.... CommitChanges back to the SQL Server database
8) Repeat steps 4-7 for each table you want to copy over
9) Once done, read up on DTS and learn how it could have saved you from hours of doing it the hard way.
10) Vow that next time, you'll swear you'll use DTS.

-tg
 
You said you are "unable". What does that mean? Your legs are broken and you can't get to your computer? You don't know how to insert records into a database? You've written some code but it throws an exception? That's what I meant about being more specific. I'm not going to waste my time writing a big explanation from start to finish if you've already done most of it yourself. How about you try to help us help you? Think about what you would need to help someone with a problem. Would "I am unable" be sufficient information?
 
thank u for ur response
i ll try this approach

TechGnome said:
Here's what you will need to do:
1) Make sure the destination tables exist in the SQL Server.
2) Open a connection to FoxPro
3) Open connection to SQL Server
4) Select the data from FP and put it into a DataSet/DataTable
5) Select from the SQL Server the corresponding table (yes, I know it'll be blank, we're getting the table schema, which is what we really want)
6) For each DataRow in the FP DT.... create a new DataRow for the SQL DT and add it
7) Once done copy the data from one DataTable to the other.... CommitChanges back to the SQL Server database
8) Repeat steps 4-7 for each table you want to copy over
9) Once done, read up on DTS and learn how it could have saved you from hours of doing it the hard way.
10) Vow that next time, you'll swear you'll use DTS.

-tg
 
jmcilhinney said:
You said you are "unable". What does that mean? Your legs are broken and you can't get to your computer? You don't know how to insert records into a database? You've written some code but it throws an exception? That's what I meant about being more specific. I'm not going to waste my time writing a big explanation from start to finish if you've already done most of it yourself. How about you try to help us help you? Think about what you would need to help someone with a problem. Would "I am unable" be sufficient information?

Thanks for making my day - and it's only just begun.... "legs broken" hehehe.... That's very much like my analogy that I use about going to the doctor's and saying you hurt... it's just something you don't do. You explain that you were skatebaording, hit a rock, fell and sliced your arm open. Not only does that explain the pain... but quite possibly the blood too.

-tg
 
Back
Top