473,395 Members | 1,556 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Need Help with SQL Statement Please

62
Hello

I am writing an address book application.

I want to be able to search for Surnames starting with a particular character let's say "A". The character is getting passed in a String to my business class. I am using Access 2007.

I have: SELECT * FROM Address WHERE Surname LIKE '" + str + "'

But I am getting an Error : Missing Syntax. I know th eabove is incorrect as I only want to retrun record starting with the Character passed.

E.G A return all Surnames starting with A , B return all Surnames starting with B etc.

Any help or recommendations would be greatly appreciated.

Thanks,

Lóan
Nov 30 '07 #1
3 1175
MikeTheBike
639 Expert 512MB
Hello

I am writing an address book application.

I want to be able to search for Surnames starting with a particular character let's say "A". The character is getting passed in a String to my business class. I am using Access 2007.

I have: SELECT * FROM Address WHERE Surname LIKE '" + str + "'

But I am getting an Error : Missing Syntax. I know th eabove is incorrect as I only want to retrun record starting with the Character passed.

E.G A return all Surnames starting with A , B return all Surnames starting with B etc.

Any help or recommendations would be greatly appreciated.

Thanks,

Lóan
Hi

Assuming this is in VBA then something like this

SQL = "SELECT * FROM Address WHERE Surname LIKE '" & str & "*'"

?

MTB
Nov 30 '07 #2
LoanB
62
Hi

Thanks for Input.

I'm using C#, Seems right from what I've read, but It return nothing.

Any other clues?

Thanks again,
Nov 30 '07 #3
LoanB
62
Hey Mike,
Just got it.:

sql = "SELECT Surname, Name, Telephone FROM Address WHERE Surname LIKE '" + str + "%'";

Thanks a mil. Your input was they key.

Happy coding,
Nov 30 '07 #4

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

Similar topics

8
by: Nathan Pinno | last post by:
Hi all, I need help figuring out how to fix my code. I'm using Python 2.2.3, and it keeps telling me invalid syntax in the if name == "Nathan" line. Here is the code if you need it. #This...
20
by: andy.rich | last post by:
I am getting the following error and I do not know why. Can anyone help? -------------------------------------------------------- this is what appears on the screen...
1
by: Jill | last post by:
I am trying to store the current date to an ms access database on my server. I set it up with a dsnless connection. Here is the statement: Insert Into employees(timestamp) Values ('" & date() &...
2
by: Mike Button | last post by:
Hello all, I am really really desperate on what I should do, and I am asking for help from anyone in this newsgroup, here's the situation: I am creating a form that is being run on a server...
2
by: clinttoris | last post by:
Hello, If someone could help me it would be appreciated as I am not having much luck. I'm struggling with my asp code and have some questions relating to asp and oracle database. First...
22
by: the_grove_man | last post by:
I purchased a book titled "Pro ASP.NET 2.0" to get up to speed on web stuff because I ususally do Windows Form Applications.. But in the first chapters I was reading this week it brought to mind...
1
by: teddymeu | last post by:
Hi Guys, trying to bulk insert a csv file into my SQL database from an asp.net vb web app/form page that the user uploads, my problem is that im new to all this and although the SQL statement...
14
namcintosh
by: namcintosh | last post by:
Hello, everyone. Well, let me cut to the chase and explain my problem. I am trying to devise a menu plan that uses the if/else if and the while loop. The program calculates the user's weight...
9
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result...
6
by: zaina | last post by:
hi everybody i am nwebie in this forum but i think it is useful for me and the member are helpful my project is about connecting client with the server to start exchanging messages between...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.