Solved

VB Code that Copy ALL DataBase Structure and Data From SQLServer 2000 DB  To another SQLServer2000 DB

Posted on 2007-12-05
3
155 Views
Last Modified: 2013-12-25
Hi there,
As the title implies I want a VB 6.0 code that copy a SQL Server DB to another SQL Server DB with the whole data in the database including the structure of the tables
0
Comment
Question by:Co0L_DBA
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 38

Expert Comment

by:PaulHews
ID: 20413204
You can use SQLDMO to transfer a database from one server to another.  Scroll down to the Sql Transfer samples

http://www.sqldev.net/sqldmo/SamplesVB6.htm
0
 
LVL 17

Accepted Solution

by:
Shanmuga Sundaram earned 500 total points
ID: 20418492

Dim rs As New ADODB.Recordset
Dim cn As New ADODB.Connection
Dim sourcedatabase As String
Dim targetdatabase As String
   
Private Sub Command1_Click()
Set rs = New ADODB.Recordset
rs.Open "select *  FROM INFORMATION_SCHEMA.TABLES", cn, adOpenKeyset, adLockOptimistic
Do Until rs.EOF
sql = "select * into " & targetdatabase & ".dbo." & rs.Fields(2) & " from " & sourcedatabase & ".dbo." & rs.Fields(2)
cn.Execute sql
rs.MoveNext
Loop
End Sub

Private Sub Form_Load()
sourcedatabase = "KR_DB"
targetdatabase = "KR_DB3"
Set cn = CreateObject("ADODB.Connection")
Set m_objRecordset = CreateObject("ADODB.Recordset")
cn.Open "dsn=dss;uid=youruserid;pwd=yourpassword" 'this uses dsn to create connection.
cn.DefaultDatabase = sourcedatabase
End Sub
0
 
LVL 17

Expert Comment

by:Shanmuga Sundaram
ID: 20418498
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question