?
Solved

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

Posted on 2007-12-05
3
Medium Priority
?
159 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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

719 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