Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Iron Speed
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old September 12th, 2003, 02:59 PM
boonkongw boonkongw is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 4 boonkongw User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation VB Query Problem

I have a problem to create a query in vb which use access database. I want to search an employername John's Cafe from table EmployerInfo
The query as follow:
Stsql = "Select * from EmployerInfo where EmployerName = 'John's Cafe' "
It shows the syndax Error message!

Anybody knows how to solve this query. Thank you.

Reply With Quote
  #2  
Old September 12th, 2003, 04:06 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 15 h 34 m 6 sec
Reputation Power: 180
The query looks OK to me.

Reply With Quote
  #3  
Old September 13th, 2003, 03:45 PM
Psaxtiris Psaxtiris is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Athens - Greece
Posts: 41 Psaxtiris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
i think problem is here << 'John's Cafe' >>

try this

dim tex as string
tex= "John's Cafe"
Stsql = "Select * from EmployerInfo where EmployerName = ' "+ tex +" ' "

Reply With Quote
  #4  
Old September 13th, 2003, 04:42 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 15 h 34 m 6 sec
Reputation Power: 180
Psaxtiris has better eyesight The embedded ' in John's Cafe is probably the problem.

For MS databases, you need to escape the single ' with two of them.

Stsql = "Select * from EmployerInfo where EmployerName = 'John' 's Cafe' "

You can use the Replace function to turn all the single apostrophes into double one's (ignore extra spaces added for readability):

str = " 'John's Cafe' "
str = Replace (str, " ' ", " ' ' ")

Reply With Quote
  #5  
Old September 16th, 2003, 05:02 PM
K_SAJESH K_SAJESH is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 9 K_SAJESH User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up

HELLO,

The Queries having special caracters especially Single Quote i.e. '; Double Quote i.e. " and Pipe i.e. | will always give you problem

as the query that you have used contains single Quote it is obvious to give you problem.

Stsql = "Select * from EmployerInfo where EmployerName = 'John's Cafe' "

for that you can either reatrict these caracters by checking the keyascii in key press event or keycode in keydown event

E.g.
If KeyAscii = 34 Or KeyAscii = 39 Or KeyAscii = 124 Then
KeyAscii = 0
Exit Sub
End If

this code will prevent the user from entering the special caracters.

or you have to attach One more same special caracter along with it as shown below.

Select * from CustomerMaster where CustName = 'John''s Cafe'

Reply With Quote
  #6  
Old December 19th, 2003, 01:00 AM
tkapal tkapal is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 3 tkapal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi!

Here is the code i have and it works but some last data in the memo field is missing.

Private Sub Command16_Click()
On Error GoTo Err_Command16_Click

Dim oApp As Object
Dim SvcList As Control
Dim varItem As Variant
Dim SvcTitle As String
Dim SvcDetail As String



Set SvcList = Me!SvcTitleList

Set oApp = GetObject(, "Word.Application")


For Each varItem In SvcList.ItemsSelected

SvcTitle = Nz(SvcList.Column(1, varItem)) & vbCrLf

SvcDetail = Nz(SvcList.Column(1, varItem)) & vbCrLf & vbCrLf & _
Nz(SvcList.Column(2, varItem)) & vbCrLf & vbCrLf


With oApp
.ActiveDocument.Bookmarks("Services").Range.Text = SvcTitle
.ActiveDocument.Bookmarks("SvcDetailBM").Range.Text = SvcDetail

End With


Next varItem
Exit_Command16_Click:
Exit Sub

Err_Command16_Click:
MsgBox Err.Description
Resume Exit_Command16_Click

End Sub

Thanks again,
tkapal

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > VB Query Problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway