Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Get rid of special characters when pulling a SQL field

Posted on 2004-08-11
8
Medium Priority
?
434 Views
Last Modified: 2010-05-18
How do I get a field from a table and get rid of all the $ . or ,? AND is this right to get rid of the / in date of a field in sql?
The example I am using is from VB and I need this to work in VB.net.

1: field to get rid of $ . and , are:
inv_amt


2: the fields  from SQL are inv_dat and rpt_date:
      invdatebat = Format(rst!inv_dat, "mmddyy")
      rptdatebat = Format(rst!inv_date, "mmddyy")

Thanks in advance for the help.



0
Comment
Question by:klb37777
[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
  • 3
  • 3
  • 2
8 Comments
 
LVL 8

Expert Comment

by:nishikanth
ID: 11781154
Try this

String.Format("{0:c}",x);

where X is the VAriable...

------------


Dim nValue as Integer
nValue as Integer=Val(strValue.Text.Remove(0,1)) 'If it is positive we need only to remove the first character "$"

If nValue=0 Then    '  --> Test for the positive value
 nValue=Val(strValue.Text.Remove(0,2)) ' --> If it is zero it means that it is negative, so we have to remove the first two characters "($"
End If

-----------------
Dim converted as string = System.Text.RegularExpressions.Regex.Replace(Gross, @"\(|\)|,|$", String.Empty)
0
 
LVL 8

Expert Comment

by:nishikanth
ID: 11781179
also this
http://www.rgagnon.com/jsdetails/js-0063.html

For dates

DATEVARIABLE.ToString("dd/mm/yyyy")
0
 
LVL 18

Accepted Solution

by:
DotNetLover_Baan earned 2000 total points
ID: 11783509
Hi there,
For inv_amt:  
First get the value of this field in string variable (Str_inv_amt), then replace those characters with ""...
Str_inv_amt = Str_inv_amt.Replace("$","")
Str_inv_amt = Str_inv_amt.Replace(".","")
Str_inv_amt = Str_inv_amt.Replace(",","")

For invdatebat,rptdatebat:
First get the values of those two fields in two string variables (Str_invdatebat, Str_rptdatebat), then format them..
Str_invdatebat = Format(Str_invdatebat,"MMddyy")
Str_rptdatebat = Format(Str_rptdatebat,"MMddyy")

-Baan
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:klb37777
ID: 11787207
Baan: are you assuming that the field name in the table is inv_amt?

nishikanth: not sure if I can use that here, but it may be useful regardless.

0
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 11787690
ya... isn't it ? oops....
0
 

Author Comment

by:klb37777
ID: 11787720
no...i didn't tell you what it was...LOL it is inv_amt, rpt_date, inv_dat
0
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 11788453
I thought this is your new project....
well, you still can do the same thing... question is WHEN ?.. ok, whenever you get the values and store it to the variables. If you are unsure of getting the values from database... well, my first choice is DataReader. Because, you are going to read the dataTable rows one by one. I would suggest first concentrate on reading the values from database. Then comes formatting.
If you have already done it, show me how you did it ? Then I can help in formatting. :)
0
 

Author Comment

by:klb37777
ID: 11790116
This is a new part of the project...the last big thing...it was suppose to have been done differently pulled from the tables and sent thru DTS pkg, of course not - not for me....

Thanks for the help, b/c I am so confused with this part. As for the main application, I just have to get that onfocus working and the reformat at the end and it should be okay for deployment. So far I haven't gotten those to worked out yet though. :(

Let me close this question since you answered my question...thanks!!!
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

618 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