472,789 Members | 1,305 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,789 software developers and data experts.

SQL Query Tool Issue In VB 2005

Hrm, I'm not at all sure my title is clear, but I spent 15 minutes trying to figure out what my real problem was. I'm new here, and brand new to VB and I'm only trying to access a database, search through it, and subsequently display it after the query has finished.

Expand|Select|Wrap|Line Numbers
  1.   Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
  2.         Dim state As String
  3.         state = StateTextBox.Text
  4.         FindByState(state)
  6.         If CustInfoDataSet.tblNames.Count = 0 Then
  7.             MessageBox.Show("No records found.", "Search Results")
  8.         End If
  10.     End Sub
This calls...

Expand|Select|Wrap|Line Numbers
  1. Private Sub FindByState(ByVal state As String)
  2.         CustInfoDataSet.Clear()
  3.         Me.TblNamesTableAdapter.FillBy(Me.CustInfoDataSet.tblNames)
  4.     End Sub
Now, FillBy is my custom query, which reads:

Expand|Select|Wrap|Line Numbers
  1. SELECT        fldKey, fldEmail, fldFirst, fldLast, fldHomePhone, fldWorkPhone, fldCellPhone, fldStreet, fldCity, fldState, fldPostalCode
  2. FROM            tblNames
  3. WHERE        (fldState = '" & state & "')
I'm positive that my query here is the culprit. When I hit search I get no results no matter what. However, if I change '" & state & "' to something like 'NC' or 'TN', states that are in my database, it works just fine, pulling up the proper clients who live in those respective states.

Please tell me this is just a syntax issue, because I've been trying to get this VERY simple code to work for days and I'm pulling my hair out. Sorry for being such a newbie, but alas, I had to start somewhere.

If I'm completely leaving something out that you guys need to know, just tell me. It's 5:11 in the morning so I'm sure I forgot something.

Thanks in advance, really appreciate any help you guys can give me.
Oct 3 '07 #1
5 1338
8,127 Expert 4TB
Try this

Expand|Select|Wrap|Line Numbers
  1. "SELECT  fldKey, fldEmail, fldFirst, fldLast, fldHomePhone, fldWorkPhone, fldCellPhone, fldStreet, fldCity, fldState, fldPostalCode
  2. FROM  tblNames WHERE  fldState = '" & state & "'"
Oct 3 '07 #2
I'm not sure what exactly changed besides the parenthesis. It auto adds them to my entry when it reformats my code. I c&ped it into my query and again it still says no results.

I'm using Access database (OLE DB). Forgot to mention that earlier, and obviously its pretty important. Sorry for that.

It seems that this is down to it not seeing the value of state. "state" being a variable, is it the syntax of the query? What I guess I'm asking is could it be something else?

I know the database if fine, because I coded in a show all button.


Expand|Select|Wrap|Line Numbers
  1. Private Sub btnShowAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShowAll.Click
  2.         CustInfoDataSet.Clear()
  3.         Me.TblNamesTableAdapter.Fill(Me.CustInfoDataSet.tblNames)
  4.     End Sub
This refreshes the table and shows all my original information at runtime, so that rules out the database itself being the problem.

I'm still trouble shooting, but I keep hitting brick walls. I have a book on 2003, but it's very little help, since it's quite obvious database connectivity got a major overhaul in 2005.
Oct 3 '07 #3
8,127 Expert 4TB
Question moved to .NET forum.
Oct 3 '07 #4
Ah, thank you and sorry I posted in the wrong area. Didn't realize, appreciate the assistance.
Oct 3 '07 #5
I'm still currently trying to figure this one out, I've found ways around this, by actually making a seperate form, that has a place to type in everything, so each individual txtbox has its one value.

Unfortunately this method doesn't fit my design, so I'm still searching for a way to fix this problem.
Oct 4 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

by: 73blazer | last post by:
We are migrating a customer from Version 7.1 FP3, to Version 8.2 (8.1 FP8). For the most part, things are faster, but there is one query that is much much slower, and it is a query that is used all...
by: vamichael | last post by:
When I try to run the Website Administration Tool from my published application using http://localhost/myapp/webadmin.axd I am getting a "resource not found" error message. I can use the...
by: Durumdara | last post by:
Hi ! I have a problem. I have a little tool that can get data about filesystems and wrote it in python. The main user asked me a GUI for this software. This user is needed a portable...
by: clare at snyder.on.ca | last post by:
I have a SQL query I need to design to select name and email addresses for policies that are due and not renewed in a given time period. The problem is, the database keeps the information for every...
by: sebnunes | last post by:
Hi all, I have a strange behavior with the ASP .NET 2.0 Admin tool. When I click on ASP.NET Configuration in VS 2005 the Administration intro page displays correctly but when I click on any...
by: Darin L. Miller | last post by:
I'm not too good with advanced SQL queries, so please bear with me on this. I have a query with multiple joins that I am trying to get just the last 10 of each unique record (RecordID)...
by: Darsin | last post by:
Hi, I have three tables with there fields given in brackets: User: (PK), Divisions: (PK), DivisionsOfUsers: , the "DivisionsOfUsers" tables has many-to-many relationships between userid...
by: chudson007 | last post by:
Hi All, What are the pros and cons between using Enterprise Manager or Query Analyzer for my queries. Currently I use Enterprise Manager because I prefer the interface and only use Query...
by: Kirk | last post by:
Hello, I am a somewhat experienced VS 2005 user who is trying to us the ASP.NET Web Site Administration Tool for the first time. I have experimented with it on my local IIS and it seems to be...
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: lllomh | last post by:
How does React native implement an English player?
by: Mushico | last post by:
How to calculate date of retirement from date of birth
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.