Error when using a field value with spaces in sql statement

B

Bill

I am having problems getting this code below to work. I am not why this is
happening, I am a novice programmer and this is the first big project I've
done. So the problem is when I execute the following sql statement I get a
eof/bof error and it only occurs when the value of the column Team has a
space in it ie(The Team)

all relevant code: -
-------------------------------------------------------

strteam = Request.Form("form_team")
CheckTeamsSQL = "Select * from tblteams WHERE TeamMembers ='" & strusername
& "'"
Set rsCheckTeam = dbConn.Execute(CheckTeamsSQL)
If rsCheckTeam.eof Then
TeamInfoSQL = "Select * from tblteams WHERE Captain = True and Team ='"&
strteam &"'"
set rsTeamInfo = dbConn.Execute(TeamInfoSQL)

strmotto = rsTeamInfo.fields("Motto")
rs.Fields("Motto") = strmotto

-------------------------------------------------
and the value from the form is a list menu generated dynamically so the
value is always whats in the database.

So I guess what I need help with is why I cant have spaces, I so believe
that I have had fields with spaces before and it worked. and if I cant have
spaces how would you convert spaces into something else to put into the
database and then still display the correct names with spaces. Thanks for any
help
 
S

Stefan B Rusynko

You should not be getting an eof just because of the space in the field data (if the filed
Not all of your code snippet is relevant to your problem

Try testing with:

strteam = Request.Form("form_team")
resposne.write strteam & "<br>"
TeamInfoSQL = "Select * from tblteams WHERE Captain = True and Team ='"& strteam &"'"
resposne.write TeamInfoSQL & "<br>"
set rsTeamInfo = dbConn.Execute(TeamInfoSQL)
resposne.write rsTeamInfo("Team") & "<br>"




|I am having problems getting this code below to work. I am not why this is
| happening, I am a novice programmer and this is the first big project I've
| done. So the problem is when I execute the following sql statement I get a
| eof/bof error and it only occurs when the value of the column Team has a
| space in it ie(The Team)
|
| all relevant code: -
| -------------------------------------------------------
|
| strteam = Request.Form("form_team")
| CheckTeamsSQL = "Select * from tblteams WHERE TeamMembers ='" & strusername
| & "'"
| Set rsCheckTeam = dbConn.Execute(CheckTeamsSQL)
| If rsCheckTeam.eof Then
| TeamInfoSQL = "Select * from tblteams WHERE Captain = True and Team ='"&
| strteam &"'"
| set rsTeamInfo = dbConn.Execute(TeamInfoSQL)
|
| strmotto = rsTeamInfo.fields("Motto")
| rs.Fields("Motto") = strmotto
|
| -------------------------------------------------
| and the value from the form is a list menu generated dynamically so the
| value is always whats in the database.
|
| So I guess what I need help with is why I cant have spaces, I so believe
| that I have had fields with spaces before and it worked. and if I cant have
| spaces how would you convert spaces into something else to put into the
| database and then still display the correct names with spaces. Thanks for any
| help
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top