Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

set field to blank with sql

Posted on 2004-08-18
11
Medium Priority
?
426 Views
Last Modified: 2012-05-05
I have a simulated drag and drop between list boxes. I need to set one of the fields to blank if draged to one of the boxes. Every thing works but that. I'm trying single quotes within the double quotes. I've tried Null too but nothing seems to work.
Here is the line in question:
SQL = SQL & "TeamCode = ''"
I want teamcode to be "" (Blank)
Any suggestions?



SQL = "UPDATE tbl_PlayerInfo SET "
      Select Case DropCtrl.Name
      Case "TeamPlayers"
    SQL = SQL & "TeamCode =" & "'" & Forms!frm_Teamcode!Tcodecmbo & "'"
      Case "ReqPlayers"
    SQL = SQL & "TeamCode = '', ReqTeam = " & "'" & Forms!frm_Teamcode!Tcodecmbo & "'"
      Case "NPlayers"
    SQL = SQL & "TeamCode = ''"
      Case "VPlayers"
    SQL = SQL & "TeamCode =" & "'" & Forms!frm_Teamcode!Vteam & "'"
   End Select
   
   If (Shift And CTRL_MASK) = 0 Then
   SQL = SQL & " WHERE [tbl_PlayerInfo.ID]=" & DragCtrl
   End If

   DB.Execute SQL

thanks
Ray
0
Comment
Question by:rembocanoe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 20

Expert Comment

by:dsacker
ID: 11838058
Try this:

SQL = SQL & "TeamCode = """""
0
 
LVL 20

Expert Comment

by:dsacker
ID: 11838063
The trick is that two doublequotes equals one displayed doublequote, hence the five doublequotes will actually be two displaying one, two more displaying one, then the final doublequote ending the string definition.
0
 

Author Comment

by:rembocanoe
ID: 11838128
didn't work..
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 20

Expert Comment

by:dsacker
ID: 11838156
Can you display the value of SQL and verify that your SQL statement shows that TeamCode = ""?

Also, it may be that you need to add a space between whatever SQL had in it and the forthcoming case logic that appends to it, else you may have the last word of the previous part of that SQL string and the first word of the appended string in your case logic WITHOUT a space in between them. You can verify that by displaying the value of SQL as you go along.
0
 

Author Comment

by:rembocanoe
ID: 11838180
I used a msgbox to check my variable and it is TeamCode = "".

What I ended up doing is setting it to TeamCode = " " then changed my list query to find " " as well as Null and "". This fixed my problem but didn't teach me anything. LOL

Thanks
Ray
0
 
LVL 20

Expert Comment

by:dsacker
ID: 11838234
Seems you should have been able to assign SQL = SQL & "TeamCode = Null" to begin with, but your original posting sounded like you had tried that. Technically, that's the cleanest way.
0
 
LVL 1

Expert Comment

by:Parag_Gujarathi
ID: 11838572
Use SQL & "TeamCode = ' '" i.e. put a blank space between the single quotes. No space between single quotes is treated as NULL!

cheers
Parag.
0
 
LVL 19

Accepted Solution

by:
Melih SARICA earned 2000 total points
ID: 11841987
Try this


SQL = SQL & "TeamCode = null "


Melih SARICA
0
 
LVL 2

Expert Comment

by:Shahankit
ID: 11846339
Try This

set escape \
SQL = SQL & "TeamCode= \"Null" "

OR
SQL = SQL & "TeamCode =" & Null

good Luck
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question