Hoping someone can help me out:
I have a fairly simple windows application that uses an Access database. I'd like to bind textboxes to my dataset, but am unsure where I'm going wrong... The problem is, upon "GotFocus" of a certain textbox, I want to open a dataset and keep it open (disconnected, of course) for editing. When hitting a "Save" button, I want to apply any changes to the dataset and update the database. The problem I have is: most of the documentation I've found focuses around datagrids, and I'm not wanting to display this data in a grid. It's a typical windows form. So the question is: How can I open a dataset in my GotFocus event, but then have that same dataset available "in scope" at the "click" event for my Save button? I'm quite the newbie, so I apologize for the simple question, but I'm really stuck! I have a feeling I'm not using the best method to create my DataSet, but I'm a bit lost... Here's a small piece of my source code:
Private Sub txtScore1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtScore1.GotFocus
Dim ds As DataSet = ExecuteDataSet("SELECT ScoreA1 FROM results where cardnum = 239 and compnum = '114'"
End Sub
Main.vb (module)
Function ExecuteDataSet(ByVal sSQLString As String) As DataSet
Dim da As New OleDbDataAdapter(sSQLString, strConn)
Dim ds As New DataSet
da.Fill(ds)
Return ds
End Function
I guess another question would be: If I create the DataSet in an event, it's not available anywhere else, right? If not, then how do I create it so that it's available upon hitting the "Save" button? ...confused!...
Thanks!
Steve
I have a fairly simple windows application that uses an Access database. I'd like to bind textboxes to my dataset, but am unsure where I'm going wrong... The problem is, upon "GotFocus" of a certain textbox, I want to open a dataset and keep it open (disconnected, of course) for editing. When hitting a "Save" button, I want to apply any changes to the dataset and update the database. The problem I have is: most of the documentation I've found focuses around datagrids, and I'm not wanting to display this data in a grid. It's a typical windows form. So the question is: How can I open a dataset in my GotFocus event, but then have that same dataset available "in scope" at the "click" event for my Save button? I'm quite the newbie, so I apologize for the simple question, but I'm really stuck! I have a feeling I'm not using the best method to create my DataSet, but I'm a bit lost... Here's a small piece of my source code:
Private Sub txtScore1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtScore1.GotFocus
Dim ds As DataSet = ExecuteDataSet("SELECT ScoreA1 FROM results where cardnum = 239 and compnum = '114'"
End Sub
Main.vb (module)
Function ExecuteDataSet(ByVal sSQLString As String) As DataSet
Dim da As New OleDbDataAdapter(sSQLString, strConn)
Dim ds As New DataSet
da.Fill(ds)
Return ds
End Function
I guess another question would be: If I create the DataSet in an event, it's not available anywhere else, right? If not, then how do I create it so that it's available upon hitting the "Save" button? ...confused!...
Thanks!
Steve