/

I'm using Microsoft Visual Web Developer 2008 to make a website and I have an access data source on the page linked to a table with a bunch of cities listed. There is a Grid View on the page linked to the data source. Also on the page I have a text box and a button. What I want to happen is the user to type in a zip code, press the button, and for it to update the grid view to show the results.

This is the code that I have:

Protected Sub Search_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Search.Click
        AccessDataSource1.InsertCommand = "SELECT * FROM [AvailRides] WHERE StartZip =" & ZipSearch.Text

    End Sub

However, this isn't working. Any help?

Recommended Answers

All 2 Replies

Hi

Pls. use SQL query viz

strQuery = "Select Zipcode from Ziptable where Zipcode like '%" & your param &" %'"

Pls. make sure to change your approriate db connection string

Public Function LoadData(ByVal StrQuery As String) As DataSet
        Try
            Dim con As New MySqlConnection(GetConnection.ToString)
            Dim cmd As New MySqlCommand(StrQuery, con)
            Dim ds As New DataSet
            Dim da As New MySqlDataAdapter(cmd)

            
            If con.State = ConnectionState.Open Then
                con.Close()
            End If
            con.Open()
            da.Fill(ds)
            If IsNothing(ds) Then
                ds = Nothing
                Return ds
            Else
                Return ds
            End If

        Catch ex As Exception
            Throw ex
        End Try
        
    End Function

Pls. mark as solved if it helps you.

Regards

Sorry I'm not very familiar with ASP.NET so I may be wrong but that doesn't seem to take input from a text box and search a table.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.