LoginSignup
0
0

More than 1 year has passed since last update.

smallbasicでsql

Last updated at Posted at 2015-05-20

自前のエクステンション使います。

サンプル

GraphicsWindow.BackgroundColor = "skyblue"
textbox = Controls.AddTextBox(10, 40)
Controls.SetSize(textbox, 400, 20)
Controls.SetTextBoxText(textbox, "select * from test")
button = Controls.AddButton("run", 420, 30)
mtextbox = Controls.AddMultiLineTextBox(10, 80)
Controls.SetSize(mtextbox, 400, 300)
Controls.ButtonClicked = onclick
Sub onclick
  WC = Text.GetCharacter(34)
  CRLF = Text.GetCharacter(13) + Text.GetCharacter(10)
  text = Controls.GetTextBoxText(textbox)
  code = ""
  code = code + "Function setup(a)" + CRLF 
  code = code + "Set con = CreateObject("+WC+"ADODB.Connection"+WC+")" + CRLF 
  code = code + "con.ConnectionString = "+WC+"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\a2000.mdb"+WC + CRLF 
  code = code + "con.Open" + CRLF 
  code = code + "Set rs = CreateObject("+WC+"ADODB.Recordset"+WC+")" + CRLF 
  code = code + "sql = "+WC+text+WC + CRLF 
  code = code + "rs.Open sql, con, 1" + CRLF 
  code = code + "Do While rs.EOF <> True" + CRLF 
  code = code + "setup = rs("+WC+"name"+WC+") & "+WC+": "+WC+" & rs("+WC+"des"+WC+") & "+WC+" ["+WC+" & rs("+WC+"txt"+WC+") & "+WC+"]"+WC+"" + CRLF 
  code = code + "rs.MoveNext" + CRLF 
  code = code + "Loop" + CRLF 
  code = code + "End Function" + CRLF
  a = Class1.VBSrun(code)
  Controls.SetTextBoxText(mtextbox, a)
EndSub

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0