none
Database example RRS feed

  • General discussion

  • There have been loads of questions and ideas on creating databases in Small Basic over the years.

    Here is a generic example not using any extensions of a database with column sorting and file storage.  I tried to code it in a general way so it could be modified or extended easily to any specific database application.

    Import GJV656.

    Sunday, September 13, 2015 3:08 PM
    Moderator

All replies

  • Thank you very much.

    Small Basic is a great tool. It is interesting and useful. I like it.

    Sunday, September 13, 2015 4:10 PM
  • Hi Litdev,

    great sample. But one info for You. to press the Tab-Key it spring to next row not to next col. By pressing Shift-Tab it spring better to the previous col. I do not know to change this. Do You has a tip?

    For expert of SQLite or other SQL-Database can rewriting for this.

    I love Your samples.


    Best Regards Martin



    • Edited by martmen Monday, September 14, 2015 4:10 PM
    Monday, September 14, 2015 4:07 PM
  • The tab order is probably related to the order the textbox controls were created - by row on the inner loop.

      'Create grid of textboxes for data
      For j = 1 To nCol
        nChar = Text.GetLength(header[j]) 'Try to center title (using fixed width font)
        GraphicsWindow.BrushColor = "MidnightBlue" 'Title Colour
        GraphicsWindow.DrawText(space-nChar*4.5+(space+tbWidth)*(j-0.5),space+tbHeight/4,header[j])
        GraphicsWindow.BrushColor = "SteelBlue" 'TextBox Colour
        For i = 1 To nRow
          tb[i][j] = Controls.AddTextBox(space+(space+tbWidth)*(j-1),space+(space+tbHeight)*(i))
          Controls.SetSize(tb[i][j],tbWidth,tbHeight)
          'Make it easy to get row,col [i][j] from textbox name
          tbRow[tb[i][j]] = i
          tbCol[tb[i][j]] = j
        EndFor
      EndFor

    We could try to rewrite this with the text boxes being created on the inner loop by column in stead of row.  Perhaps like this:

      'Create header text
      For j = 1 To nCol
        nChar = Text.GetLength(header[j]) 'Try to center title (using fixed width font)
        GraphicsWindow.BrushColor = "MidnightBlue" 'Title Colour
        GraphicsWindow.DrawText(space-nChar*4.5+(space+tbWidth)*(j-0.5),space+tbHeight/4,header[j])
        GraphicsWindow.BrushColor = "SteelBlue" 'TextBox Colour
      EndFor
      'Create grid of textboxes for data - col on inner loop to be able tab by column
      For i = 1 To nRow
        For j = 1 To nCol
          tb[i][j] = Controls.AddTextBox(space+(space+tbWidth)*(j-1),space+(space+tbHeight)*(i))
          Controls.SetSize(tb[i][j],tbWidth,tbHeight)
          'Make it easy to get row,col [i][j] from textbox name
          tbRow[tb[i][j]] = i
          tbCol[tb[i][j]] = j
        EndFor
      EndFor
    


    Tuesday, September 15, 2015 5:35 AM
    Moderator
  • LitDev, this would make a great blog post. Would you like to post it? Or do you want me to?

    Thanks!


    Ed Price, Azure & Power BI Customer Program Manager (Blog, Small Basic, Wiki Ninjas, Wiki)

    Answer an interesting question? Create a wiki article about it!

    Tuesday, October 6, 2015 12:00 AM
    Owner
  • I'll do it - thanks
    Tuesday, October 13, 2015 9:13 PM
    Moderator
  • Litdev,

    Great simple database example. Good graphics. Compact code and just plain looks nice.


    JR

    Saturday, November 7, 2015 9:45 PM
    Answerer