Hi, I'm a beginner in vb.net, I need to save the (settings) or created buttons in runtime into my database so that the next time I run the application. the created buttons are still available.
How do I save the created buttons with its functions in runtime using my way of saving to database? any ideas?
My ideas was.. Saving the created buttons in runtime and then I'll loop the add handler at next formload so that I am only going to retrieve the buttons in my database and add its function during form load.
Sorry for the trouble of the way I'm saving the controls, someone told me to stick to what I know and create my application as fast as possible.
FYI: My Visual Basic coding knowledge isn't very strong, so I may require some explanations etc.
Connection String
Dim dssettings As New DataSet
Dim dasettings As New OleDbDataAdapter
Dim sqlsettings, settings As String
Public Sub connection()
conMain.Dispose()
conMain.ConnectionString = "Provider=MSDAORA.1;Data Source=xe;Password=testing;User ID=testing;Connection Timeout=20"
conMain.Open()
End Sub
Form1Connection()
sqlsettings = "Select * From settings"
dasettings = New OleDbDataAdapter(sqlsettings, conMain)
dssettings.Clear()
dasettings.Fill(dssettings, "settings")
End Sub
Saving Controls to Database either I'll use Addrow or Update
Dim cb As New OleDb.OleDbCommandBuilder(dasettings)
dssettings.Tables("settings").Rows(1).Item("settings") = settings
dasettings.Update(dssettings, "settings")
Sample Create button
Dim Choicebutton As New Button
With ChoiceButton
.Location = New Point(0, 380)
.Size = New Size(380, 50)
.Name = "test"
.Text = "test"
End With
AddHandler Choicebutton.Click, AddressOf ChoiceButton_Click
Sample Added Handler
Public Sub Choicebutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim buttonThatWasClicked As Button = DirectCast(sender, Button)
MessageBox.Show("You Clicked a Button with the text: " & buttonThatWasClicked.Text)
End Sub