Visual Studio....MS Access database modifying.

Visual Studio....MS Access database modifying.

To modify a MS Access database in Visual Studio 2005:

Visual Studio -> View -> Server Explorer. Under Data Connections, right-click MS Access database and select Modify Connection to enter username and password. Or instead of selecting "Modify Connection", select "Refresh" to connect to db.

////////////////////////////////////////////////////
Create table with no fields:
///////////////////////////////////////////////////

CREATE TABLE tblStores

///////////////////////////////////////////////////
Create table with with fields:
///////////////////////////////////////////////////

CREATE TABLE tblPersons
(P_Id AUTOINCREMENT PRIMARY KEY )
 
CREATE TABLE tblStores
(Store_ID INT NOT NULL, Store_Name CHAR, Store_Address CHAR, Store_City CHAR, Store_State CHAR, Store_Zip CHAR)
 
CREATE TABLE tblTwitter
( Twitter_Int_ID INT PRIMARY KEY NOT NULL, Twitter_Ext_ID  CHAR, Twitter_UserName CHAR, Twitter_Auth_Key1 CHAR, Twitter_Auth_Key2  CHAR )
 
CREATE TABLE tblTwitterx
( Twitter_Int_ID COUNTER NOT NULL, Twitter_Ext_ID  CHAR, Twitter_UserName CHAR, Twitter_Auth_Key1 CHAR, Twitter_Auth_Key2  CHAR )

///////////////////////////////////////////////////
Delete an entire table:
///////////////////////////////////////////////////

DROP TABLE tblStores

///////////////////////////////////////////////////
Insert row into a table:
///////////////////////////////////////////////////

INSERT INTO Persons (P_Name)
VALUES     ('TestName')

///////////////////////////////////////////////////
Alter table  - column type:
///////////////////////////////////////////////////

ALTER TABLE tblStores
ALTER COLUMN Store_ID AUTOINCREMENT PRIMARY KEY

////////////////////////////////////////////////////
Alter table - add column
///////////////////////////////////////////////////

ALTER TABLE Persons
ADD DateOfBirth date

///////////////////////////////////////////////////
Alter Table - delete a column
///////////////////////////////////////////////////

ALTER TABLE Persons
DROP COLUMN DateOfBirth

///////////////////////////////////////////////////
Rename table
///////////////////////////////////////////////////

SELECT * INTO tblStoresCorp FROM tblStores
DROP TABLE tblStores

 

What did you think of this article?




Trackbacks
  • Trackbacks are closed for this post.
Comments
  • No comments exist for this post.
Leave a comment

Comments are closed.