FUDforum
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 
Switch to threaded view of this topic Create a new topic Submit Reply
Create mysql database using mysql command [message #168578] Mon, 27 May 2013 06:54 Go to next message
Jack Hard is currently offline  Jack Hard
Messages: 7
Registered: December 2012
Karma: 0
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())
{
con.Open();

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

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

try
{
cmd.ExecuteNonQuery();
}
catch (Exception exc)
{
return;
}
cmd.Dispose();
con.Close();
con.Dispose();
}

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?
Re: Create mysql database using mysql command [message #186575 is a reply to message #168578] Fri, 03 October 2014 13:27 Go to previous messageGo to next message
ash is currently offline  ash
Messages: 2
Registered: October 2014
Location: nashik
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
to create a database in mysql we used a command
create database database_name;

then we used that database using,
use database_name;

then create a table
create table table_name;


ASHISH DUSANE
Re: Create mysql database using mysql command [message #186576 is a reply to message #168578] Fri, 03 October 2014 13:31 Go to previous messageGo to next message
ash is currently offline  ash
Messages: 2
Registered: October 2014
Location: nashik
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
we create database in mysql by using command
create database database_name;


ASHISH DUSANE
Re: Create mysql database using mysql command [message #186943 is a reply to message #186576] Tue, 04 August 2015 11:07 Go to previous message
motorinsurance16 is currently offline  motorinsurance16
Messages: 1
Registered: August 2015
Location: London
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
Thats also how I create databases in my own work
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
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: Sat Oct 21 21:13:56 EDT 2017

Total time taken to generate the page: 0.00723 seconds