|
-
February 15th, 2010, 05:36 AM
#1
dataset question
hi,
my script is working fine, i have a button that executes a query and fill my dataset.
but when i click again the button and execute the query it is just adding it to my dataset.
i need to reset the dataset when i click the button, because it is a new query.
Code:
Private Sub bttnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnStart.Click
Dim conn As New OleDbConnection()
conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\ApplicationKit.accdb"
Dim MyVariable As String
Dim ChosenBttn As String
Dim Vowel As String
Dim Table As String
Table = "Word"
Vowel = "Word"
MyVariable = cbPhonemes.SelectedIndex
MyVariable = MyVariable + 1
If bttnInitial.Checked = True Then
ChosenBttn = "Initial"
End If
If bttnMedial.Checked = True Then
ChosenBttn = "Medial"
End If
If bttnFinal.Checked = True Then
ChosenBttn = "Final"
End If
Dim strSQL As String = "SELECT word, meaning FROM word WHERE (ID = " & MyVariable & ") AND ( [Position] = '" & ChosenBttn & "')"
Dim da As New OleDbDataAdapter(strSQL, conn)
da.Fill(ds)
If ds.Tables(0).Rows.Count > 0 Then 'Check to see if the table is empty
lblWord.Text = ds.Tables(0).Rows(0).Item("Word").ToString()
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|