Table Adapters and fillbywhere

DekaFlash

Well-known member
Joined
Feb 14, 2006
Messages
117
Programming Experience
1-3
I'm in the process of modifying my project to work with table adapters only rather then a combination of table and data adapters.

How do I set up my code so it displays data only containing the entered date?

VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If (RaceDate.Text.Length = 0) Then
            ' Do Nothing
        Else
            Dim RaceDateString As String = Me.RaceDate.Text.Trim 'Me.RaceDate.Text.Substring(6, 1).ToString + Me.RaceDate.Text.Substring(7, 1).ToString() + Me.RaceDate.Text.Substring(8, 1).ToString + Me.RaceDate.Text.Substring(9, 1).ToString + Me.RaceDate.Text.Substring(5, 1).ToString + Me.RaceDate.Text.Substring(3, 1).ToString + Me.RaceDate.Text.Substring(4, 1).ToString + Me.RaceDate.Text.Substring(2, 1).ToString + Me.RaceDate.Text.Substring(0, 1).ToString + Me.RaceDate.Text.Substring(1, 1).ToString
            MsgBox(RaceDateString.ToString)
            Me.VsrDataTableAdapter.SelectCommand(0).CommandText = "select * from VsrData"

            Dim stWhere As String = ""

            If RaceDateString <> "" Then

             stWhere = "RaceDate = " + RaceDateString
MsgBox(28)
                MsgBox(stWhere.ToString)
            End If

            If stWhere = "" Then
                Me.VsrDataTableAdapter.Fill(Me.EquinexMasterSqlDataSet.VsrData)
                MsgBox(33)
            Else
                Me.VsrDataTableAdapter.FillByWhere(Me.EquinexMasterSqlDataSet.VsrData, stWhere)

            End If
        End If
    End Sub
 
You don't. If you want to build SQL statements on the fly then you use a DataAdapter, not a TableAdapter.

One thing you could is create a partial class for your TableAdapter and expose the DataAdapter inside via a public property but then what's the point? You're using a DataAdapter anyway.

You did know that a TableAdapter is just a wrapper for a Connection and a DataAdapter, right?
 

Latest posts

Back
Top