MySql Tutrial(creating a database/tables useing ASP)
this is the code for connection to the mysql server
(before creating the databse!)
Set Con = Server.CreateObject ("ADODB.Connection")
Con.open = "DRIVER={MySQL ODBC 3.51 Driver};"_ & "SERVER=localhost;"_ & "DATABASE=;"_ & "UID=root;PWD=; OPTION=35;"
|
server=your server
DATABASE=your databse(for now its empty we first need to create a databse)
UID=User Name(the user name, is you didnt chang it will be root)
PWD=your Password(the password will be empty if you wont chang it)
now after we connected to mysql we need to create a database
we will do this useing the command
CREATE DATABASE
con.execute "create database database name"
|
after the databse was created we need to start useing it for creating tables later
con.execute "use database_name"
|
for creating a table we will use the command
CREATE TABLE
con.execute "create table TableName(ID INT NOT NULL auto_increment," &_ "field_name VARCHAR(250) NOT NULL, PRIMARY KEY(ID))"
|
comman field types:
VARCHAR - same as text in Access
TEXT - same as memo in Access
INT - same as number in Access
full code:
Set Con = Server.CreateObject ("ADODB.Connection")
Con.open = "DRIVER={MySQL ODBC 3.51 Driver};"_
& "SERVER=localhost;"_
& "DATABASE=;"_
& "UID=root;PWD=; OPTION=35;"
con.execute "create database database name"
con.execute "use database_name"
con.execute "create table TableName(ID INT NOT NULL auto_increment," &_
"field_name VARCHAR(250) NOT NULL, PRIMARY KEY(ID))"
Con.Close set Con = nothing
Response.write("finnished!")
|