I have this problem, which I hope you guys can help me with.
I use vs2010 and create a program using vb2010, with that I have a splashscreen which loads at program startup and should copy all the records from a mysql database table into a local ms access database table ( they are the same).
At startup the splashscreen should also check if the mysql database is available, this works, but when I add some code to copy from database to database it doesn't work and I get the message that the host isn't available (error message I've added).
Also with the error message, I added a button to it (the standard messagebox), when the message is shown, it closes the message after a couple of seconds but should remain until I click the OK button.
Here is the code I use, hope you can help me with this.
Thanks for any help.
I use vs2010 and create a program using vb2010, with that I have a splashscreen which loads at program startup and should copy all the records from a mysql database table into a local ms access database table ( they are the same).
At startup the splashscreen should also check if the mysql database is available, this works, but when I add some code to copy from database to database it doesn't work and I get the message that the host isn't available (error message I've added).
Also with the error message, I added a button to it (the standard messagebox), when the message is shown, it closes the message after a couple of seconds but should remain until I click the OK button.
Here is the code I use, hope you can help me with this.
VB.NET:
Imports MySql.Data.MySqlClient
Imports System.Data.OleDb
Public NotInheritable Class StartScreen1
Dim con As New MySqlConnection("Server=" + My.Settings.OnlineHost + ";Database=" + My.Settings.OnlinedbName + ";Uid=" + My.Settings.OnlineUser + ";Pwd=" + My.Settings.Onlinepw)
Dim accesscon As New OleDb.OleDbConnection
Dim mycommand As New MySqlCommand
Dim myadapter As New MySqlDataAdapter
Dim Accessadapter As New OleDbDataAdapter
Dim mydata As New DataTable
Dim mydataset As New DataSet
Dim SQL As String
'TODO: This form can easily be set as the splash screen for the application by going to the "Application" tab
' of the Project Designer ("Properties" under the "Project" menu).
Private Sub StartScreen1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
If My.Computer.Network.Ping("IP") Then
'Set up the dialog text at runtime according to the application's assembly information.
'TODO: Customize the application's assembly information in the "Application" pane of the project
' properties dialog (under the "Project" menu).
accesscon.ConnectionString = ("Provider+" + My.Settings.Offlineprovider + ";Data Source=" + My.Settings.AccesssourceOff)
SQL = "SELECT * FROM songs"
Try
con.Open()
mycommand.Connection = con
mycommand.CommandText = SQL
myadapter.SelectCommand = mycommand
myadapter.Fill(mydataset, "songs")
accesscon.Open()
Accessadapter.Update(mydataset, "songs")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
'Application title
If My.Application.Info.Title <> "" Then
ApplicationTitle.Text = My.Application.Info.Title
Else
'If the application title is missing, use the application name, without the extension
ApplicationTitle.Text = System.IO.Path.GetFileNameWithoutExtension(My.Application.Info.AssemblyName)
End If
'Format the version information using the text set into the Version control at design time as the
' formatting string. This allows for effective localization if desired.
' Build and revision information could be included by using the following code and changing the
' Version control's designtime text to "Version {0}.{1:00}.{2}.{3}" or something similar. See
' String.Format() in Help for more information.
'
' Version.Text = System.String.Format(Version.Text, My.Application.Info.Version.Major, My.Application.Info.Version.Minor, My.Application.Info.Version.Build, My.Application.Info.Version.Revision)
Version.Text = System.String.Format(Version.Text, My.Application.Info.Version.Major, My.Application.Info.Version.Minor, My.Application.Info.Version.Build, My.Application.Info.Version.Revision)
'Copyright info
Copyright.Text = My.Application.Info.Copyright
End If
Catch
'MsgBox("Host is not available!" & vbNewLine & _
' "Make sure you have an internet connection and try again later!")
Dim button As DialogResult
button = MessageBox.Show _
("Host is not available!" & vbNewLine & _
"Make sure you have an internet connection and try again later!", _
"Songlist Editor", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)
If button = Windows.Forms.DialogResult.OK Then
' Application.Exit()
Else
'Do Nothing
End If
'Dim messge2 As DialogResult
'messge2 = MessageBox.Show( _
' "The host is not available." & vbNewLine & _
' "Make sure you have an internet connection and try again later!", My.Application.Info.Title, _
' MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
'Application.Exit()
End Try
End Sub
End Class
Thanks for any help.