Search an access database

Reply

Join Date: Nov 2008
Posts: 2
Reputation: Zebu00 is an unknown quantity at this point 
Solved Threads: 0
Zebu00 Zebu00 is offline Offline
Newbie Poster

Search an access database

 
0
  #1
Nov 22nd, 2008
/

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:
  1. Protected Sub Search_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Search.Click
  2. AccessDataSource1.InsertCommand = "SELECT * FROM [AvailRides] WHERE StartZip =" & ZipSearch.Text
  3.  
  4. End Sub

However, this isn't working. Any help?
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 119
Reputation: reach_yousuf is an unknown quantity at this point 
Solved Threads: 19
reach_yousuf reach_yousuf is offline Offline
Junior Poster

Re: Search an access database

 
0
  #2
Nov 23rd, 2008
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
  1. Public Function LoadData(ByVal StrQuery As String) As DataSet
  2. Try
  3. Dim con As New MySqlConnection(GetConnection.ToString)
  4. Dim cmd As New MySqlCommand(StrQuery, con)
  5. Dim ds As New DataSet
  6. Dim da As New MySqlDataAdapter(cmd)
  7.  
  8.  
  9. If con.State = ConnectionState.Open Then
  10. con.Close()
  11. End If
  12. con.Open()
  13. da.Fill(ds)
  14. If IsNothing(ds) Then
  15. ds = Nothing
  16. Return ds
  17. Else
  18. Return ds
  19. End If
  20.  
  21. Catch ex As Exception
  22. Throw ex
  23. End Try
  24.  
  25. End Function

Pls. mark as solved if it helps you.

Regards
Last edited by reach_yousuf; Nov 23rd, 2008 at 12:56 am.
Yousuf
Software Developer
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 2
Reputation: Zebu00 is an unknown quantity at this point 
Solved Threads: 0
Zebu00 Zebu00 is offline Offline
Newbie Poster

Re: Search an access database

 
0
  #3
Nov 23rd, 2008
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 663 | Replies: 2
Thread Tools Search this Thread



Tag cloud for ASP.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC