473,656 Members | 2,793 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

delimiters, sql, joins, AHHH!

Ok, I posted in here a few days ago about a problem with apostrophes in text
fields and I tried a few of the suggestions and now I'm in so deep I looking
at scraping the whole thing because now I don't know where to begin. If
fixing it looks like it will take longer than starting over then I suppose I
should let this ship sink and swim to shore and regroup.

Here's the way I started. Not the best way I'm sure. I'm self taught so
for those of you that did this in college you have have an idea of what I'm
going through and all the pitfalls and chasms I keep falling into. Anyway,
here's the summary of my mess.

I started entering info into an Access db before I wrote a line of code. 2
tables: gigs and places. I wanted to keep "places" separate from "gigs" to
keep prevent redundant info in the db. This way (I thought) it would be
easier this way so the "places" info would always be there to call on
instead rewriting it everytime and if something new came up to provide and
opportunity for the user to enter the info separately then just reuse it as
it came up. I was going to "cheat" and just create separate recordsets...an
RS for "gigs" then just create another for "places". WELL don't we have
quite a mess now!! Arg. Here the problems I've run into...

It started with the delimiter problems. The apostrophes in text fields
wreaked havoc on my data calls. I've been evil and using "SELECT *" so it
hasn't come up in sql strings "yet". The problems came when I tried to
match records in recordsets to something generated in loops...like looping
records in a select tag in html to produce all the options in a dropbox.
The problem was with apostrophes the record would stop writing when it hit
that first apostrophe in the text field. SO I tried using "Replace" to turn
them all into ´ that ended up creating a bigger mess (and html kept
interpreting ´ into ' so I could get them to mesh) and in the DB so
the more I mess with the worse things got...chasing the train as it were...

I did try to go back and change the Replace to "''" rather than "´"
(hard to read, ain't it) thats quote 2 apostrophes quote. I didn't
understand that in prior posts until later. By this time this thing is a
mess......

I messed with Access and tried using the lookup wizard to link the tables
but, as you know, that produces numeric ID's so around and around we
go.....AAHHHH!

So then I start reading up on JOIN's, inner's, outer's, left's ,right,s.
None of them seem to be what I need (and I'm just getting a handle on
sql)...and my head is spinning while I watch the clock run out on this
project. I AM GOING NUTS!!!

Oh, and this is the site by the way. the front end is done. It's the
backend, the users admin side, that's causing all the problems.
http://thehalftonhorns.com

So this is what I what to do...

1). have 2 tables, "gigs" and "places"
2). be able to call on and update both in recordsets

Here's a list of books I have on hand if you want to point me in a direction
you know of...
Beginning Active Server Pages 3.0 (Wrox)
Beginning ASP Databases (Wrox)
Beginning Javascript (Wrox)
HTML Complete
MSDN Library -Visual Studio 6.0 (disk)

I really hope someone can help on this. I'm driving my wife and kids nuts
locked in this room for days turning into "monster daddy".

Thanks!!!!
John
Jul 22 '05 #1
10 2265
John wrote:
Ok, I posted in here a few days ago about a problem with apostrophes
in text fields and I tried a few of the suggestions and now I'm in so


To decide whether or not to delimit the data, look at the datatype of the
FIELD - NOT THE DATA.
1. If it's a numeric field, you must supply it with numeric data, which
means you MUST NOT delimit the data by putting quotes around it.
2. If it's a character/text field, then you must supply string data by
delimiting the data either with single or double quotes. If the data
contains literal quotes, you must escape them by doubling them. This means
that if you use single quotes (apostrophes) for your string delimiters, and
the data contains an apostrophe, then you must replace the apostrophe with
two apostrophes, like this:
Update tbl set textfield = 'O''Malley'
In Access, you can use double quotes for your delimiters, so this will work
as well:
Update tbl set textfield = "O'Malley"
Note: you don't have to escape the apostrophe in O'Malley when you use
double quotes as the delimiter. However, you will need to escape the double
quotes when assigning this statement to a variable:
sSQL = "Update tbl set textfield = ""O'Malley" ""
So most people will use the single quotes and escape the apostrophe:
sName = "O'Malley"
sSQL = "Update tbl set textfield = '" & Replace(sName," '","''") & "'"
response.write sSQL

3. If it's a date/Time field, then the delimiters depend on the type of
database. Since you are using Access, then you must delimit the data with
hash marks (#). Additionally, you must supply the data in US format
(m/d/yyyy) or in ISO (yyyy-mm-dd), with the latter being the more
recommended.

4.Lastly, if you are using LIKE, you need to be aware that you must use %
and _ as the wildcards, not * and ?. This is true no matter what database
you are using

And then, when you think you have it right and it still does not work,
response.write it to see the result of your concatenation. If you've done it
correctly, you will have a statement that you can copy and paste from the
browser window into the SQL View of an Access Query Builder and run without
modification (unless you need to replace the wildcards with the Jet
wildcards).

Here's more:

http://groups.google.com/groups?hl=e...tngp13.phx.gbl

http://groups.google.com/groups?hl=e...TNGP11.phx.gbl

http://www.google.com/groups?selm=eE...&output=gplain

http://www.google.com/groups?hl=en&l...TNGP12.phx.gbl

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 22 '05 #2
I'm doing this but I still can't get the recordset to match what is being
edited. I'm just not seeing it??

<%
Set rsGigPlace = Server.CreateOb ject("ADODB.Rec ordset")
gigPlaceSQL = "SELECT * FROM places ORDER BY placeName ASC;"
rsGigPlace.Curs orType = 3
rsGigPlace.Open gigPlaceSQL, gigsCon

Response.write _
"<select name='location' >"
While Not rsGigPlace.EOF
Response.write _
"<option value='" & rsGigPlace("pla ceName") & "'"
If Replace(rsGigPl ace("placeName" ),"'","''") =
Replace(rsGigEd it("gigPlace"), "'","''") Then Response.write "selected" End
If
Response.write _
">" & rsGigPlace("pla ceName") & "</option>"
rsGigPlace.Move Next
Wend
rsGigPlace.Clos e
Set rsGigPlace = nothing
Response.write "</select>"
%>

(rsGigEdit is from another recordset still open)

the html being produced....
<td>
<select name='location' ><option value='Benefit Concert'>Benefi t
Concert</option><option value='Fat Moe's'>Fat Moe's</option><option
value='Froggy's '>Froggy's</option><option value='George Eastman
House'>George Eastman House</option><option
value='Georgio' s'>Georgio's</option><option value='TBA'>TBA </option><option
value='The Panorama'>The Panorama</option></select>
</td>
2. If it's a character/text field, then you must supply string data by
delimiting the data either with single or double quotes. If the data
contains literal quotes, you must escape them by doubling them. This means
that if you use single quotes (apostrophes) for your string delimiters, and the data contains an apostrophe, then you must replace the apostrophe with
two apostrophes, like this:
Update tbl set textfield = 'O''Malley'
In Access, you can use double quotes for your delimiters, so this will work as well:
Update tbl set textfield = "O'Malley"
Note: you don't have to escape the apostrophe in O'Malley when you use
double quotes as the delimiter. However, you will need to escape the double quotes when assigning this statement to a variable:
sSQL = "Update tbl set textfield = ""O'Malley" ""
So most people will use the single quotes and escape the apostrophe:
sName = "O'Malley"
sSQL = "Update tbl set textfield = '" & Replace(sName," '","''") & "'"
response.write sSQL

Jul 22 '05 #3
> 2. If it's a character/text field, then you must supply string data
by
delimiting the data either with single or double quotes. If the data
contains literal quotes, you must escape them by doubling them. This means that if you use single quotes (apostrophes) for your string delimiters, and the data contains an apostrophe, then you must replace the apostrophe with two apostrophes, like this:
Update tbl set textfield = 'O''Malley'
In Access, you can use double quotes for your delimiters, so this will work as well:
Update tbl set textfield = "O'Malley"


I think it would be recommended that you use single quotes, so that
if/when you move this from Access to SQL, you won't have to go in and
rewrite so much code.

Jul 22 '05 #4
John wrote:
I'm doing this but I still can't get the recordset to match what is
being edited. I'm just not seeing it??
Oh you're problem is not in creating the query? It's displaying the results?
<%
Set rsGigPlace = Server.CreateOb ject("ADODB.Rec ordset")
gigPlaceSQL = "SELECT * FROM places ORDER BY placeName ASC;"
Don't use selstar: http://www.aspfaq.com/show.asp?id=2096
rsGigPlace.Curs orType = 3
rsGigPlace.Open gigPlaceSQL, gigsCon

Response.write _
"<select name='location' >"
While Not rsGigPlace.EOF
Response.write _
"<option value='" & rsGigPlace("pla ceName") & "'"
If Replace(rsGigPl ace("placeName" ),"'","''") =
Replace(rsGigEd it("gigPlace"), "'","''")
This is not necessary. Escaping the apostrophes is only necessary when
creating sql statements. All you need to do is:

If rsGigPlace("pla ceName") = rsGigEdit("gigP lace") Then
Response.write " selected"
End If

If this does not work, then we need to see the values being compared.

the html being produced....
<td>
<select name='location' ><option value='Benefit Concert'>Benefi t
Concert</option><option value='Fat Moe's'>Fat Moe's</option>


I would not use single-quote delimiters for the attributes. I would do this
(doubling the quote marks):

Response.write "<select name=""location "">"
Do Until rsGigPlace.EOF
Response.write "<option value=""" & _
rsGigPlace("pla ceName") & """"
If rsGigPlace("pla ceName") = rsGigEdit("gigP lace") Then
Response.write " selected"
End If
Response.write ">" & rsGigPlace("pla ceName") & "</option>"
rsGigPlace.Move Next
Loop
rsGigPlace.Clos e
Set rsGigPlace = nothing
Response.write "</select>"
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 22 '05 #5
It didn't work. What you wrote produced this...
<select name="location" ><option value="Benefit Concert">Benefi t
Concert</option><option value="Fat Moe's">Fat Moe's</option><option
value="Froggy's ">Froggy's</option><option value="George Eastman
House">George Eastman House</option><option
value="Georgio' s">Georgio's </option><option value="TBA">TBA </option><option
value="The Panorama">The Panorama</option></select>

I should add that this is how the form data is processed. Is there
something here that's adding to my problems?

gigDateMerge = Request("month" ) & "/" & Request("day") & "/" &
Request("year")
gigTimeMerge = Request("Time_h our") & ":" & Request("Time_m inute") &
Request("Time_A MPM")
gigTitle = Replace(Request ("gigTitle"),"' ","''")
gigLocation = Replace(Request ("location"),"' ","''")
gigComments = Replace(Request ("comments"),"' ","''")

Set rsGigUpdate = Server.CreateOb ject("ADODB.Rec ordset")
gigUpdateSQL = "SELECT * FROM gigs WHERE gigID=" & Request("gigID" ) & ";"
rsGigUpdate.Ope n gigUpdateSQL, gigConn, adOpenDynamic, adLockOptimisti c,
adCmdText

rsGigUpdate("gi gTitle") = gigTitle
rsGigUpdate("gi gDate") = gigDateMerge
rsGigUpdate("gi gTime") = gigTimeMerge
rsGigUpdate("gi gPlace") = gigLocation
rsGigUpdate("gi gComments") = gigComments
rsGigUpdate.Upd ate
Set rsGigUpdate = nothing
"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
John wrote:
I'm doing this but I still can't get the recordset to match what is
being edited. I'm just not seeing it??
Oh you're problem is not in creating the query? It's displaying the

results?

<%
Set rsGigPlace = Server.CreateOb ject("ADODB.Rec ordset")
gigPlaceSQL = "SELECT * FROM places ORDER BY placeName ASC;"


Don't use selstar: http://www.aspfaq.com/show.asp?id=2096
rsGigPlace.Curs orType = 3
rsGigPlace.Open gigPlaceSQL, gigsCon

Response.write _
"<select name='location' >"
While Not rsGigPlace.EOF
Response.write _
"<option value='" & rsGigPlace("pla ceName") & "'"
If Replace(rsGigPl ace("placeName" ),"'","''") =
Replace(rsGigEd it("gigPlace"), "'","''")


This is not necessary. Escaping the apostrophes is only necessary when
creating sql statements. All you need to do is:

If rsGigPlace("pla ceName") = rsGigEdit("gigP lace") Then
Response.write " selected"
End If

If this does not work, then we need to see the values being compared.

the html being produced....
<td>
<select name='location' ><option value='Benefit Concert'>Benefi t
Concert</option><option value='Fat Moe's'>Fat Moe's</option>


I would not use single-quote delimiters for the attributes. I would do

this (doubling the quote marks):

Response.write "<select name=""location "">"
Do Until rsGigPlace.EOF
Response.write "<option value=""" & _
rsGigPlace("pla ceName") & """"
If rsGigPlace("pla ceName") = rsGigEdit("gigP lace") Then
Response.write " selected"
End If
Response.write ">" & rsGigPlace("pla ceName") & "</option>"
rsGigPlace.Move Next
Loop
rsGigPlace.Clos e
Set rsGigPlace = nothing
Response.write "</select>"
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Jul 22 '05 #6
John wrote:
It didn't work. What you wrote produced this...
<select name="location" >
<option value="Benefit Concert">Benefi t Concert</option>
<option value="Fat Moe's">Fat Moe's</option>
<option value="Froggy's ">Froggy's</option>
<option value="George Eastman House">
George Eastman House</option>
<option value="Georgio' s">Georgio's </option>
<option value="TBA">TBA </option>
<option value="The Panorama">The Panorama</option>
</select>


Uuuummmm - what's wrong with this output?

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 22 '05 #7
None of the values are matching anything in the recordset which "should"
produce a "selected". I don't know why because these exact values are going
"in" to the database as far as I can see. That's why I included the the
processing end to see if I'm doing something wrong there. what's weird is
when I change a record to a place "without" an apostrophe in it it works.
it's driving me crazy! I just can't see why?

Thanks Bob!! You're my last hope of getting this done in time! 8-D
"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote in message
news:%2******** *******@TK2MSFT NGP14.phx.gbl.. .
John wrote:
It didn't work. What you wrote produced this...

<select name="location" >
<option value="Benefit Concert">Benefi t Concert</option>
<option value="Fat Moe's">Fat Moe's</option>
<option value="Froggy's ">Froggy's</option>
<option value="George Eastman House">
George Eastman House</option>
<option value="Georgio' s">Georgio's </option>
<option value="TBA">TBA </option>
<option value="The Panorama">The Panorama</option>
</select>


Uuuummmm - what's wrong with this output?

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Jul 22 '05 #8
John wrote:
None of the values are matching anything in the recordset which
"should" produce a "selected". I don't know why because these exact
values are going "in" to the database as far as I can see. That's
why I included the the processing end to see if I'm doing something
wrong there. what's weird is when I change a record to a place
"without" an apostrophe in it it works. it's driving me crazy! I
just can't see why?

Thanks Bob!! You're my last hope of getting this done in time! 8-D

I can't help without seeing the data in the recordsets. Do this:

response.write rsGigPlace.gets tring(2,," | ", "<BR>")
response.write rsGigEdit.getst ring(2,," | ", "<BR>")
response.end

And show the results, explaining which fields are relevant.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 22 '05 #9
This is what you requested produced...

5 | Benefit Concert | | Lyndonville | |
1 | Fat Moe's | 4423 Dewey Ave | Rochester | NY | 663-1860
3 | Froggy's | 1129 Empire Blvd | Webster | NY | 288-1080
6 | George Eastman House | 900 East Ave | Rochester | NY | 271-3361
2 | Georgio's | | Niagara Falls | NY |
7 | TBA | | | |
8 | The Panorama | | Gates | NY |
19 | Test gig | 1/1/2005 | 7:00:00 AM | Froggy''s | woo ha

The record I'm after is just the title, or the field right after the ID.
"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote in message
news:u$******** ******@TK2MSFTN GP10.phx.gbl...
John wrote:
None of the values are matching anything in the recordset which
"should" produce a "selected". I don't know why because these exact
values are going "in" to the database as far as I can see. That's
why I included the the processing end to see if I'm doing something
wrong there. what's weird is when I change a record to a place
"without" an apostrophe in it it works. it's driving me crazy! I
just can't see why?

Thanks Bob!! You're my last hope of getting this done in time! 8-D

I can't help without seeing the data in the recordsets. Do this:

response.write rsGigPlace.gets tring(2,," | ", "<BR>")
response.write rsGigEdit.getst ring(2,," | ", "<BR>")
response.end

And show the results, explaining which fields are relevant.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Jul 22 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2733
by: Markus Elfring | last post by:
Hello, I try to use alternative delimiters for a regular expression. When will it be supported? www@mike:/home/www > /usr/local/bin/php -a Interactive mode enabled <?php preg_match('m!A(\d*)B!', 'A12345B', $X));
3
2570
by: Justin L. Kennedy | last post by:
I am looking for a function that takes in a string and splits it using a list of other strings (delimiters) and can return the delimiters as well as the extra parts of the string. I was trying the split with a regex built up of the delimiters separated by "|", but it doesn't return the delimiters which I need. The goal is an algorithm that can take a string containing html code using <ul>, <ol>, and <li> and turn it into a formated...
2
9837
by: Bill Moran | last post by:
I'm having some problems using \copy I have a directory full of test data that I want to be installed automatically when "make database" is issued. While the Makefile rules would seem simple, I'm having some trouble. I want to do this \copy table_name from 'table_name.cdf' delimiters ','; But I get:
6
4235
m6s
by: m6s | last post by:
1. After hours of researching, I used these snippets : void Object::TokenizeLines(const string& str, vector<string>& tokens, const string& delimiters) // Skip delimiters at beginning. string::size_type lastPos = str.find_first_not_of(delimiters, 0); // Find first "non-delimiter". string::size_type pos = str.find_first_of(delimiters, lastPos); while (string::npos != pos || string::npos != lastPos) { // Found a token, add it...
4
1796
by: bearophileHUGS | last post by:
This is the best praise of semantic indentation I have read so far, by Chris Okasaki: http://okasaki.blogspot.com/2008/02/in-praise-of-mandatory-indentation-for.html A quotation: I have appreciated that article, and I have personally seen how fast students learn Python basics compared to other languages, but I think that it's way more than just indentation that makes the Python language so quick to learn .
1
2992
by: zeny | last post by:
Hey folks! Can anyone tell me how to add data to a table using "copy" with several delimiters? Is it possible? What i mean is: Copy <table_name> from <file_directory> using delimiters <delimiters>; How its done the "<delimiters>" part? I tried several ways but i got out of ideas...
5
3352
by: gpaps87 | last post by:
hi, i wanted to know whether we can use strtok command to mark delimiters as tokens as well.In Java,we have a command: StringTokennizer(String str, String delimiters, boolean delimAsToken) which considers the delimiters as tokens,too.Can strtok accomplish this requirement?or could you please let me know if there is any other command in C that would carry out this task?
4
2632
by: Marco Trapanese | last post by:
Hi, I'm trying to parse strings on an Atmel AVR device. I use the WinAVR C Compiler (GCC) The strings to parse are like this: command -par0 -par1 -parn I use strok_r function:
36
2483
by: TC | last post by:
I've used Access for many years. Several times, I've encountered a bug which I refer to as the "Vanishing Joins" bug. When it happens, joins vanish randomly from queries. More specifically, all joins vanish from at least one (seemingly random) query. I've always regarded the Vanishing Joins bug as a symptom of corruption. When it happens, I usually give my users advice on how to recover from corruption, and how to avoid it in the future....
0
8382
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8297
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8717
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8600
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5629
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1930
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.