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

x
?
Solved

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

Posted on 2014-02-10
9
Medium Priority
?
559 Views
Last Modified: 2014-02-13
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
Comment
Question by:jnoely
[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
9 Comments
 
LVL 43

Expert Comment

by:Rob
ID: 39852265
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
 
LVL 46

Expert Comment

by:aikimark
ID: 39852503
does it work if the database is enclosed in square brackets?
Example:
strExecute = "CREATE DATABASE " & "[aaaa_1]"

Open in new window

0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 39852535
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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 43

Expert Comment

by:Rob
ID: 39852545
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
 

Author Comment

by:jnoely
ID: 39855918
It does work with the 3.51  if you uses the back ticks !!! whopee
0
 

Author Comment

by:jnoely
ID: 39855920
many thanks
0
 
LVL 43

Expert Comment

by:Rob
ID: 39855930
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

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