Solved

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

Posted on 2007-12-05
3
152 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

912 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now