Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Sub createbackup()
- Using ofd As New FolderBrowserDialog
- If ofd.ShowDialog = DialogResult.OK Then
- Dim fileloc As String
- fileloc = ofd.SelectedPath
- Dim datads As New DataSet
- Dim datad2 As New DataSet
- If Not conn Is Nothing Then conn.Close()
- conn.ConnectionString = cstring()
- Try
- conn.Open()
- Dim sql1 As String
- Dim command1 As MySqlCommand
- Dim adapter1 As New MySqlDataAdapter
- Dim sql2 As String
- Dim command2 As MySqlCommand
- Dim adapter2 As New MySqlDataAdapter
- sql1 = "Select * from users"
- sql2 = "Select * from ips"
- command1 = New MySqlCommand(sql1, conn)
- command2 = New MySqlCommand(sql2, conn)
- adapter1.SelectCommand = command1
- adapter1.Fill(datads)
- adapter2.SelectCommand = command2
- adapter2.Fill(datad2)
- Main.IPData.DataSource = datads.Tables(0)
- Main.UsersData.DataSource = datad2.Tables(0)
- Main.IPData.Columns(3).DefaultCellStyle.Format = "yyyy/MM/dd"
- Catch ex As Exception
- MsgBox(ex.ToString)
- End Try
- conn.Close()
- Try
- Dim DTB = New DataTable, RWS As Integer, CLS As Integer
- For CLS = 0 To Main.IPData.ColumnCount - 1 ' COLUMNS OF DTB
- DTB.Columns.Add(Main.IPData.Columns(CLS).Name.ToString)
- Next
- Dim DRW As DataRow
- For RWS = 0 To Main.IPData.Rows.Count - 1 ' FILL DTB WITH DATAGRIDVIEW
- DRW = DTB.NewRow
- For CLS = 0 To Main.IPData.ColumnCount - 1
- Try
- ' save fix (need to format date proper
- ' If CLS = 4 Then
- DRW(DTB.Columns(CLS).ColumnName.ToString) = Main.IPData.Rows(RWS).Cells(CLS).Value.ToString
- ' else
- '
- 'End if
- Catch ex As Exception
- End Try
- Next
- DTB.Rows.Add(DRW)
- Next
- Dim DTB2 = New DataTable, RWS2 As Integer, CLS2 As Integer
- For CLS2 = 0 To Main.UsersData.ColumnCount - 1 ' COLUMNS OF DTB
- DTB2.Columns.Add(Main.UsersData.Columns(CLS2).Name.ToString)
- Next
- Dim DRW2 As DataRow
- For RWS2 = 0 To Main.UsersData.Rows.Count - 1 ' FILL DTB WITH DATAGRIDVIEW
- DRW2 = DTB2.NewRow
- For CLS2 = 0 To Main.UsersData.ColumnCount - 1
- Try
- DRW2(DTB.Columns(CLS2).ColumnName.ToString) = Main.UsersData.Rows(RWS2).Cells(CLS2).Value.ToString
- Catch ex As Exception
- End Try
- Next
- DTB2.Rows.Add(DRW2)
- Next
- DTB.AcceptChanges()
- DTB2.AcceptChanges()
- Dim DST As New DataSet
- Dim DST2 As New DataSet
- DST.Tables.Add(DTB)
- DST2.Tables.Add(DTB2)
- Dim FLE As String = "" & fileloc & "\users.xml" ' PATH AND FILE NAME WHERE THE XML WIL BE CREATED (EXEMPLE: C:\REPS\XML.xml)
- Dim FLE2 As String = "" & fileloc & "\ipaddresses.xml" ' PATH AND FILE NAME WHERE THE XML WIL BE CREATED (EXEMPLE: C:\REPS\XML.xml)
- DTB.WriteXml(FLE)
- DTB2.WriteXml(FLE2)
- Catch ex As Exception
- ' MsgBox(ex.ToString)
- End Try
- updatedatagrid(Main.UsersData, Main.Emailbox.Text)
- End If
- End Using
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement