473,322 Members | 1,188 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,322 software developers and data experts.

Replace statement for VB6

4
I have use the code below ..

Expand|Select|Wrap|Line Numbers
  1. txtName.Text = Trim(Replace(CurrRs("NAME"), "''", "'"))
  2.  
..to actually change back the double quotes stored on the database to single quote when the data calls to the screen.

as from the screen (user keyed in) to the database I used the code below; to prevent the quotation mark error from pop up.

Expand|Select|Wrap|Line Numbers
  1. CurrRs("NAME") = Trim(Replace(txtName.Text, "'", "''"))
  2.  
The code works just fine if i key in a string without any quotation mark, it'll will be stored just fine in the database but somehow problem rise when i try to key in a string with quotation mark where the new data doesn't go into the database. There's no error but it's just the data isn't going into the database.

What should i do to correct these problem?
Apr 28 '11 #1
1 1942
Killer42
8,435 Expert 8TB
Sorry to see you haven't received a response to this question.

If you have managed to answer it yourself, please let us know what you came up with, as it will help next time someone has a similar question.

If not, I have some general debugging suggestions. To begin with, try displaying the results of the expression, rather than moving it into the database field. It helps if you can isolate the problem, to simplify investigation.

In other words, we're trying to pin down whether the problem is actually the text that's coming out of the nested expressions (Trim etc) or what's going into the database.

This is where the debugging tools built into VB are very helpful. Rather than changing the code to print things out, you can simply set a breakpoint on that line, highlight the Trim(Replace(txtName.Text, "'", "''")) and see what it returns.

To be honest, I'm a bit suspicious of the Replace function here. It seems as though it could end up trying to create an infinitely-long string. Think about it - after replacing the first single quote, what is it going to find in the next position in the string? :-)
Jun 16 '11 #2

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

Similar topics

4
by: Craig Keightley | last post by:
Can these lines of sql statements be consolidated into one sql statement (possibly using reg exps??) BEGIN CODE ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Update...
8
by: middletree | last post by:
What's wrong with this code? strLongDesc = Replace(Replace(Replace(Replace(Trim(Request.Form("LongDesc")),"'","''"),vbC rLf,"<br>"),"<",&lt;),"<",&gt;) Background: This field is a textarea, and I...
1
by: Graham Mattingley | last post by:
Hi Group, I have used xmlHTTP to grab a page from a server.. The page has the '£' symbol in it, when it get to my site it is displayed as a '?'.. I have tryed replace every way I know and it...
4
by: Prasad S | last post by:
Hello I wish to replace all the characters in a string except those which are inside '<' & '>' characters. And there could be multiple occurences of < & > within the string. e.g. string =...
3
by: Andy Sutorius | last post by:
Hi, I read the thread (2/16/05) regarding a replace function in C# however it didn't answer my question. I have a string which is building an insert sql statement and I would like to replace...
4
by: Jack | last post by:
Hi, I have a asp page where part of the code is as follows. This builds up the sql statement partially. sql01 = "UPDATE EquipmentTbl SET " sql01 = sql01 & "SerialNumber = '" &...
1
by: David | last post by:
Hello, Quick question. If I have a whole list of text, (Technical Specifications), I understand that I can replace keystrokes with line breaks etc. What if my listing needs to like something...
10
by: Noozer | last post by:
Writing some ASP code and I need to take a string, representing a phone number, and strip out some characters, namely spaces, brackets and hyphens. I could write pNum=replace(pNum," ","")...
2
by: Jeremy | last post by:
I am trying to replace a string "P" with "\P" as long as the string "P" does not already have a "\" in front. for my search string I've used @"(P)" so my regex replace statement is: ...
1
benchpolo
by: benchpolo | last post by:
SQL Query SELECT mh.hpcode , ISNULL(CONVERT(varchar,mh.opfromdt,112),'') as opfromdt , ISNULL(CONVERT(varchar,mh.opthrudt,112),'') as opthrudt , mc.patid , mc.membid , mc.lastnm ,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.