Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. data migration

data migration

Scheduled Pinned Locked Moved Visual Basic
databasehelpsysadmin
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    divyaswati
    wrote on last edited by
    #1

    please help me in completing this module i want to transfer the data from one database to another within the same server. But there is a problem of identity column that exist in the table and it will unable the code to transfer the data within the new database my coding is Dim ObjSrcConnection As System.Data.SqlClient.SqlConnection Dim ObjDesConnection As System.Data.SqlClient.SqlConnection Dim TableListConn As SqlConnection Dim cmd As SqlCommand Dim ObjSrcCommand As SqlCommand Dim ObjDesCommand As SqlCommand Dim da As SqlDataAdapter Dim ds As New DataSet Dim dr As SqlDataReader Dim dt As New DataTable Dim query As String Dim TableName As String Dim TableListConnString As String Dim strConSrc As String Dim strConDest As String Dim string1 As String Dim TableQuery As String Dim strCol As String Dim strType As String Dim sqlQuery As String Dim intJ As Integer Dim intK As Integer Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnGetTable.Click Validation() Table() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnMigrate.Click TableName = ListTable.Text strConSrc = "server=" & txtSrcServer.Text.Trim & ";user id=" & txtUser.Text.Trim & ";password=" & txtPwd.Text.Trim & ";database=" & txtSrcDb.Text.Trim & "" strConDest = "server=" & txtDesServer.Text.Trim & ";user id=" & txtDesUser.Text.Trim & ";pwd=" & txtDesPwd.Text.Trim & ";database=" & txtDesDb.Text.Trim & "" ObjSrcConnection = New SqlConnection(strConSrc) ObjSrcConnection.Open() ObjDesConnection = New SqlConnection(strConDest) 'con2.ConnectionString = strConDest ObjDesConnection.Open() TableQuery = "select * from " & TableName ObjSrcCommand = New SqlCommand(TableQuery, ObjSrcConnection) dr = ObjSrcCommand.ExecuteReader(CommandBehavior.CloseConnection) dt = dr.GetSchemaTable Dim i As Integer = dt.Rows.Count For intJ = 0 To i - 1 If intJ = 0 Then strCol = dt.Rows(intJ).Item(0).ToString() Else strCol = strCol & "," & dt.Rows(intJ).Item(0).ToString() End If Next If find1() = True Then Exit Sub End If While dr.Read() Try 'sqlQuery = "Ins

    C 1 Reply Last reply
    0
    • D divyaswati

      please help me in completing this module i want to transfer the data from one database to another within the same server. But there is a problem of identity column that exist in the table and it will unable the code to transfer the data within the new database my coding is Dim ObjSrcConnection As System.Data.SqlClient.SqlConnection Dim ObjDesConnection As System.Data.SqlClient.SqlConnection Dim TableListConn As SqlConnection Dim cmd As SqlCommand Dim ObjSrcCommand As SqlCommand Dim ObjDesCommand As SqlCommand Dim da As SqlDataAdapter Dim ds As New DataSet Dim dr As SqlDataReader Dim dt As New DataTable Dim query As String Dim TableName As String Dim TableListConnString As String Dim strConSrc As String Dim strConDest As String Dim string1 As String Dim TableQuery As String Dim strCol As String Dim strType As String Dim sqlQuery As String Dim intJ As Integer Dim intK As Integer Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnGetTable.Click Validation() Table() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnMigrate.Click TableName = ListTable.Text strConSrc = "server=" & txtSrcServer.Text.Trim & ";user id=" & txtUser.Text.Trim & ";password=" & txtPwd.Text.Trim & ";database=" & txtSrcDb.Text.Trim & "" strConDest = "server=" & txtDesServer.Text.Trim & ";user id=" & txtDesUser.Text.Trim & ";pwd=" & txtDesPwd.Text.Trim & ";database=" & txtDesDb.Text.Trim & "" ObjSrcConnection = New SqlConnection(strConSrc) ObjSrcConnection.Open() ObjDesConnection = New SqlConnection(strConDest) 'con2.ConnectionString = strConDest ObjDesConnection.Open() TableQuery = "select * from " & TableName ObjSrcCommand = New SqlCommand(TableQuery, ObjSrcConnection) dr = ObjSrcCommand.ExecuteReader(CommandBehavior.CloseConnection) dt = dr.GetSchemaTable Dim i As Integer = dt.Rows.Count For intJ = 0 To i - 1 If intJ = 0 Then strCol = dt.Rows(intJ).Item(0).ToString() Else strCol = strCol & "," & dt.Rows(intJ).Item(0).ToString() End If Next If find1() = True Then Exit Sub End If While dr.Read() Try 'sqlQuery = "Ins

      C Offline
      C Offline
      Coolesh
      wrote on last edited by
      #2

      SET indentity_insert YourTable ON here goes insert SET indentity_insert YourTable OFF Robert

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups