Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently October 19th, 2024, 11:19 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: How to get my variable to replace all spaces with underscore
PostPosted: June 5th, 2015, 2:27 pm 
Offline

Joined: May 12th, 2015, 2:04 pm
Posts: 47
Opus: Opus 9.5
OS: Win 8
System: Intel Core i7 3.6Ghz
Good day,

I am trying to create a table with the users name and idnumber as the name of the table, the code works fine except when the user's name got a space somewhere then no table will be created in MSACCESS (I don't know why), do anybody know the solution to this problem, or how can I force the "loginuser" to leave out all the spaces or be replaced by a underscore

Code:
var myDB = new Database("FILEDSN=C:\\Backup\\CBT\\Published\\J281 Ross Operators\\Data\\database.dsn");
myDB.ExecuteSQL("CREATE TABLE " + loginuser + "_" + loginidnumber + "  (street varchar(15))");


Please help.


For this message Matra has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: How to get my variable to replace all spaces with unders
PostPosted: June 15th, 2015, 2:20 pm 
Offline

Joined: June 18th, 2005, 3:16 pm
Posts: 86
Opus: Opus Pro v9.75
OS: Windows 10.?
System: HP xw660 Server 32GB RAM, Toshiba Satellite Laptop
Your question has been sitting here for a while so I thought that I would resolve it today. The attached example is self-explanatory and shows two solutions to your 'no spaces in the name problem':

1. let the user enter the text naturally, then remove with a tiny amount of script as shown in the example when you press the button.

2. in the input box untick the 'allow special characters option'. The disadvantage is that hyphenated names won't show either, but if the user knows that no spaces are allowed in the user name this should only result in mild grumblings from those with double-barreled names. :roll:

It is good practice to put an instruction to the user asking them not to enter spaces, then you simply trap for the typing errors they will inevitably make. :D

If you have any further queries please post them here and we'll be happy to help.

Paul


You do not have the required permissions to view the files attached to this post.

_________________
Opus 9.6
HP xw6600 Workstation, Intel64 , Intel(R) XEON(R) CPU E5430 2.7GHz, RAM 8GB, NVIDIA Quatro K600, Samsung SSD 840 Pro Series: 238.5GB , 2 x 1TB HDD, 2 x PnP Generic monitors
Living a long, healthy, happy & prosperous life!


For this message pc_amethyst has been thanked by : mackavi


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group