0

I want to search through an sql table called hardware for a partial serial numbers.

I have the following code but there is something wrong with the way i am doing my
sql query. hope someone out there can help me.

Public Function GetDatabysn() As DataView
        Dim SelectQry = "SELECT * FROM hardware where serial= like %'" & Me.TextBox1.Text & " %'"
        Dim SampleSource As New DataSet
        Dim TableView As DataView
        Try
            Dim SampleCommand As New SqlCommand()
            Dim SampleDataAdapter = New SqlDataAdapter()
            SampleCommand.CommandText = SelectQry
            SampleCommand.Connection = Connection
            SampleDataAdapter.SelectCommand = SampleCommand
            SampleDataAdapter.Fill(SampleSource)
            TableView = SampleSource.Tables(0).DefaultView
        Catch ex As Exception
            Throw ex
        End Try
        Return TableView
    End Function
1
Contributor
1
Reply
14
Views
6 Years
Discussion Span
Last Post by Mike Bishop
0

hi everyone one i have sorted it with the following code

Dim SelectQry = "SELECT * FROM hardware where serial like'%" & Me.TextBox1.Text & "%'"

        Dim SampleSource As New DataSet
        Dim TableView As DataView
        Try
            Dim SampleCommand As New SqlCommand()
            Dim SampleDataAdapter = New SqlDataAdapter()
            SampleCommand.CommandText = SelectQry
            SampleCommand.Connection = Connection
            SampleDataAdapter.SelectCommand = SampleCommand
            SampleDataAdapter.Fill(SampleSource)
            TableView = SampleSource.Tables(0).DefaultView
        Catch ex As Exception
            Throw ex
        End Try
        Return TableView
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.