Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » General » PHP discussions » Create mysql database using mysql command
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Return to the default flat view Create a new topic Submit Reply
Create mysql database using mysql command [message #168578] Mon, 27 May 2013 06:54 Go to previous message
Jack Hard is currently offline  Jack Hard
Messages: 7
Registered: December 2012
Junior Member
add to buddy list
ignore all messages by this user

I am having a problem when trying to create a database using mysql command. The code i am using is;

using (MySqlConnection con = connect_db())

MySqlCommand cmd = new MySqlCommand("CREATE DATABASE @name;", con);

cmd.Parameters.AddWithValue("@name", "fancydb");

catch (Exception exc)

When i try to run this code i always get an error saying that i have an error in mysql syntax near "fancydb"...but when I put the name in the command like: "CREATE DATABASE facnydb;" it works. Can anyone explain to me why is the error only happening when i try and use parameters?
[Message index]
Read Message
Read Message
Read Message
Read Message
Previous Topic: Debugging an embedded device using TCF
Next Topic: Using PHP to send mail
Goto Forum:

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Feb 27 00:02:29 EST 2020

Total time taken to generate the page: 0.00757 seconds