Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 570
  • Last Modified:

VB6 - cannot create a mysql db with a name having an underscore in it

i can create a new mysql db manually with an name having an underscore in it but cannot create it programatically .. see below with the code

   Set cnnado = New adodb.Connection
   strCon = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=192.168.1.64;"
   strCon = strCon & "DATABASE=mysql; UID=xxxx;PWD=yyyyy;OPTION=3"
   cnnado.ConnectionString = strCon
   cnnado.Open
   strExecute = "CREATE DATABASE " & "aaaa_1"
   cnnado.Execute strExecute

This code works fine for a db name 'aaaa1' but nout for 'aaaa_1' .. i can create the db manually ok eg via the command prompt and mysql or using something like sqlyog.
0
jnoely
Asked:
jnoely
1 Solution
 
RobOwner (Aidellio)Commented:
The underscore is a special character so to use it you've got to escape it or user the chr(242)
E.g.
strExecute = "CREATE DATABASE " & "aaaa" & chr(242) & "1"
0
 
aikimarkCommented:
does it work if the database is enclosed in square brackets?
Example:
strExecute = "CREATE DATABASE " & "[aaaa_1]"

Open in new window

0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I don't see why it would not accept the underscore:
http://dev.mysql.com/doc/refman/5.0/en/identifiers.html

anyhow, for MySQL that would be backticks:
strExecute = "CREATE DATABASE " & "`aaaa_1`"
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
RobOwner (Aidellio)Commented:
To clarify my comment above, I'm referring to vb syntax where the underscore is used for continuation of code on new lines and may be being interpreted incorrectly in this case
0
 
jnoelyAuthor Commented:
It does work with the 3.51  if you uses the back ticks !!! whopee
0
 
jnoelyAuthor Commented:
many thanks
0
 
RobOwner (Aidellio)Commented:
Are you sure you allocated the points right here?
If the back ticks solved your issue then the points should go to angeliii along with an A grade
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now