Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 3.5 and Visual Studio. 2008 > Visual Studio 2008
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Visual Studio 2008 For discussing Visual Studio 2008. Please post code questions about a specific language (C#, VB, ASP.NET, etc) in the correct language forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Studio 2008 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 27th, 2008, 06:26 PM
Registered User
 
Join Date: Oct 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Search button doesn't search Access DB

Hello,

I have a Microsoft Access DB connected to a Windows Form Application.
This DB is going to be used as a tracking system. I tried to code the search button to check the Access file based on a certain criteria that is typed in by the user. There are several fields:
Last Name, First Name, etc. Below is the code I have to try to have search the Access DB file. Am I missing another piece that should return the data searched? I tried checking http://msdn.microsoft.com and I have a book for windows form applications but couldn't find an answer. Any help in the right direction would be appreciated.

  Public Sub ReadMyData(ByVal myConnString As String)
  Dim mySelectQuery As String = "SELECT Medical Record Number, Last Name, First Name FROM Table1 where lastname ='" + TextBox1.Text + "'"
        Dim myConnection As New OleDbConnection(myConnString)
        Dim myCommand As New OleDbCommand(mySelectQuery, myConnection)
        myConnection.Open()
        Dim myReader As OleDbDataReader
        myReader = myCommand.ExecuteReader()
        While myReader.Read()
            Console.WriteLine(myReader.GetInt32(0).ToString() + ", " _
            + myReader.GetString(1))
        End While

Thank you.
Reply With Quote
  #2 (permalink)  
Old October 27th, 2008, 07:36 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Did you DEBUG???

Just for starters, did you put a breakpoint on the line where you create the query and make sure that the SQL was valid?

If it looks valid, did you then take that string and try it WITHIN ACCESS? See if that query actually returns anything?

p.s.: Just FYI, that query is *NOT* legal SQL. Which I guess means I know you didn't debug.

p.p.s.: Here's a hint for you: You are doing a SELECT for "Last Name" and yet your WHERE clause is trying to match up on the field "lastname". *SURELY* that table doesn't have BOTH a field named "Last Name" *and* one named "lastname". Surely.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
search button ct Excel VBA 0 April 11th, 2006 09:50 AM
Q about search DB... ugmos Classic ASP Databases 1 February 27th, 2006 07:49 PM
Create Search Button on Access Form BKILBAN Access VBA 1 February 27th, 2004 09:01 AM
Error When Trying to Search in Access DB Using ASP mvollmer Classic ASP Databases 3 October 10th, 2003 10:52 AM
Problem using wildcards to search an Access DB taliesin Classic ASP Databases 4 June 23rd, 2003 11:13 PM



All times are GMT -4. The time now is 01:24 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.