Forum Moderators: open

Message Too Old, No Replies

Create New Table in MySQL with an ASP page

is it possible?

         

MatrixBrains

2:00 pm on Jan 29, 2005 (gmt 0)

10+ Year Member



Hi,

I have created a mysql database & a dsn connection for the database, together with a username and a password for that database connection.

Now i need to create a table in this database.

I want to do it using an asp page. Is is possible? How?

Regards,
MB

MatrixBrains

6:46 pm on Jan 29, 2005 (gmt 0)

10+ Year Member



Hi,

Using the MySQL console application available on both Windows (c:\mysql\bin\mysql.exe) and Linux/Unix (/usr/local/mysql), we enter the following code to create a new database and one new table, which we will use later with MySQL commands:
---------------------------------------
create database address;

use address;

create table contacts

(

contactId int auto_increment not null,

firstName varchar(50),

lastName varchar(50),

address1 varchar(100),

address2 varchar(100),

phone varchar(20),

primary key(contactId),

unique id(contactId)

);

----------------------------

This is possible if i am running the server.

But i am not. So, i have created a database, a dsn, a username and a password for using the database.

Now, how do i create a new table using asp.

(What is the code that i put in my asp page)

Regards,
MB

txbakers

10:55 pm on Jan 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The commmands you use to connect to the database in ASP, and to execute an update , delete, insert, etc. are the same commands you use when you create tables.

dim cmd
cmd = "Create table newtable"
cmd += " contactId int auto_increment not null "
cmd.execute

that is the rough syntax for it.

MatrixBrains

6:38 am on Jan 30, 2005 (gmt 0)

10+ Year Member



Thanks buddy. I was head over heels, thinking that this is a big problem. You make it sound so simple.

Regards,
MB