Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a database that will be full of data, I want in vb net ro clone this database, rename the cloned database and delete the all data of the original database.
I want to use smo to copy/clone the database not backup the database, also any link that hekps will be great.

thank you in advance
Kyriakos

What I have tried:

I found how to delete the data.
<pre lang="VB">For Each lRow As DataRow In yourtable.Rows
   lRow.Delete
Next
Dim builder As New OdbcCommandBuilder(yourDataAdapter)
yourDataAdapter.DeleteCommand = builder.GetDeleteCommand
yourDataAdapter.Update(yourtable)
Posted
Comments
[no name] 5-Jan-22 12:37pm    
If you plan to "clone", you need a new name; you can't expect to rename later after creating a duplicate. Maybe you should use export / import instead.
Richard Deeming 6-Jan-22 4:32am    
Why the arbitrary restriction? Backup and restore is the simplest way to "clone" a database.

Don't forget, databases can contain a lot more than just the tables and data. You can have views, stored procedures, functions, roles, users, permissions, full-text catalogs, ...

1 solution

Thank toy all I will try import/export first and then backup.

Kyriakos
 
Share this answer
 
Comments
Maciej Los 6-Jan-22 14:10pm    
This is not an answer. Please, delete it to avoid down-voting. To add comment, use "Have a Question or comment" or "Reply" widget.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900