data migration
-
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
-
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