0

I'm trying to make a simple thing but it has become difficult as I do not understand why I proves a mistake like that, I'll explain , I would like to set the database name as well : "FD65F10A-0F6F-487C-A5E4-18A783DC18AE" (PID variable)

But if I leave this , I get this error :

enter image description here

the problem seems to be the hyphen , because if I remove it and septum so : FD65F10A0F6F487CA5E418A783DC18AE everything works , saves me the db and I can go way on the debug..Come I can use the hyphen ? you need to use it , I have to find a solution . Thank you

Mr. Developer
  • 3,295
  • 7
  • 43
  • 110

2 Answers2

0

You can use delimited characters for naming.

String str = "CREATE DATABASE '" + PID + "' ON PRIMARY "........

Noting the single quotes in the string on either side of the PID variable.

Kramb
  • 1,082
  • 10
  • 18
0

Not only is the database name failing, but also your LOG ON line.

Put square brackets around the database name and around the log name:

"CREATE DATABASE [" + PID + "] ..."
...
"LOG ON (NAME = [" + PID + "Log_Log] ..."
Joe Enos
  • 39,478
  • 11
  • 80
  • 136