Results 1 to 6 of 6

Thread: Create Databse in MySQL

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    310

    Create Databse in MySQL

    How to create database in my mysql if it the database name is not currently true in mysql? Using vb.net

    How to check if database name is already created or available in my localhost using vb.net.
    VB 6.0 = "Self-Study" Then
    vb.NET = "Self-Study" Then
    C# = 'on going study.....

  2. #2
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: Create Databse in MySQL

    Inside the IDE? Or when running the application? Or with some other tool?

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    310

    Re: Create Databse in MySQL

    I want to create a function that check and create a database if is not present in my localhost.
    VB 6.0 = "Self-Study" Then
    vb.NET = "Self-Study" Then
    C# = 'on going study.....

  4. #4
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: Create Databse in MySQL

    If you want to only check if the database you can do this:

    Code:
    SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'Name'
    If you want to create the DB if the DB not exists

    Code:
    CREATE DATABASE IF NOT EXISTS Name;

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    310

    Re: Create Databse in MySQL

    btw it is my sql script i want to create if the database is not exist:

    Code:
    CREATE DATABASE transaction;
    
    USE transaction;
    
    CREATE TABLE clients
    (
    	client_id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    	lastname CHAR(40) NOT NULL,
    	firstname CHAR(40) NOT NULL,
    	phone CHAR(20) NOT NULL,
    	credits CHAR(20) NOT NULL,
    )TYPE = MyISAM;
    is that possible to execute that in my form? I am using MySQL Server 5.0
    VB 6.0 = "Self-Study" Then
    vb.NET = "Self-Study" Then
    C# = 'on going study.....

  6. #6
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: Create Databse in MySQL

    Just replace the
    Code:
    CREATE DATABASE transaction;
    by
    Code:
    CREATE DATABASE IF NOT EXISTS transaction;
    Just to know, i don't know if you'll have problems with that name... to prevent why not add a prefix like dbTransaction...

    Rate People That Helped You
    Mark Thread Resolved When Resolved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width