Message while connecting to database

Hi,

i call a method (OpenMySqlDB) in my Mainwindow open-event which connects to a MySQL-Database. Because it is a remote-DB, it could take 1 or 2 seconds to connect, open the window and fill the listbox with the database records.

The “problem” is, that the user sees nothing while this happens. I know that there is a progressbar control. How would you implement a messagebox or something like this while connecting to the database? Or maybe there is a better way instead of using progressbar?


  MySqlDB = New MySQLCommunityServer
  
  MySqlDB.Host = "myHostName"
  MySqlDB.Port = 3306
  MySqlDB.UserName = "myUserName"
  MySqlDB.Password = "myPassword"

//THIS IS WHERE THE CONNECTION HAPPENS
  
  If MySqlDB.Connect Then
    MySqlDB.SQLExecute("set names utf8 collate utf8_general_ci")
    MySqlDB.SQLExecute("set character set utf8")
    MySqlDB.SQLExecute("use myDatabase")
    OfflineMode = False
    DatenbankMenuOffline.Checked = False
    DatenbankMenuOnline.Checked = True
    return
  Else
    MsgBox("Datenbankfehler: " + MySqlDB.ErrorMessage)
    OfflineMode = True
    AlwaysOffline = True
    DatenbankMenuOffline.Checked = True
    DatenbankMenuOnline.Checked = False
    Return
  End If

Michael

What about a ProgressWheel instead?

What do you mean by remote?

I add a small canvas control… and set VISIBLE=FALSE

When I start a long running process (long running as in more than a few seconds :slight_smile: )

I call this method

SUB TASK_COMPLETE(msg as string,timer_stop as boolean=false)
  Dim w As Window
  Dim c As canvas
  w=winMAIN '<---- WINDOW WITH THE CANVAS ON IT
  c=winMAIN.msg_complete
  c.Visible=false
  //c.Refresh
  app.DoEvents
  winmain.UpdateNow
  If msg<>""  Then 
    complete_text=msg
    
    If timer_stop Then winMAIN.timer_complete.mode=timer.ModeSingle
    c.Left=((w.width-c.width)\\2)
    c.top=((w.height-c.height)\\3)
    c.Visible=True
    c.refresh
    c.Invalidate
  End If
END SUB

the PAINT EVENT of the Canvas is

SUB PAINT(g as graphics,areas() as realbasic.rect)
  #pragma Unused areas
  Dim w As Integer
  Dim h As Integer
  Dim i As Integer
  Dim y As Integer
  Dim v() As String
  Dim s As String
  If complete_text="" Then Exit Sub
  g.TextFont="System"
  g.TextSize=16
  complete_text=ReplaceLineEndings(complete_text,EndOfLine.UNIX)
  v=Split(complete_text,EndOfLine.UNIX)
  w=0
  For i=0 To v.Ubound
    w=Max(w,g.StringWidth(complete_text)+8)
  Next
  Me.height=((v.ubound+1)*g.textheight)+6
  Me.Width=w+Me.height
  
  //
  h=g.height
  w=g.width
  g.ForeColor=&c3b3b3b
  g.FillRoundRect 0,0,w,h,h,h
  g.ForeColor=&caaaaaa
  g.DrawRoundRect 0,0,w,h,h,h
  g.ForeColor=color_white
  y=2+g.TextAscent
  For i=0 To v.Ubound
    s=v(i)
    w=(g.width-g.StringWidth(s))\\2
    g.DrawString s,w,y
    y=y+g.TextHeight
  Next I
END SUB

then there is a timer , which I set to 1.5 seconds (the time the message will appear o n the screen)

TIMER_COMPLETE.ACTION
  msg_complete.Visible=False
  Me.Mode=timer.ModeOff

@Eli Ott: remote means that app and db are not at the same place. there is a VPN-connection between them.

@Dave: will look at your solution and try to adapt it for my needs.

thanks.

Michael