ASP gets the database table name, field name, and some actions on the field
Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
Recently, in the ASP forum to see a lot of netizens asked how to get the database table name, field name and how to delete the field, add the operation so write this article.
I am more familiar with SQL Server, so SQL Server is the column:
SET conn=server.createobject ("ADODB. Connection ")
Conn.Open "SERVER=IP address; provider=sqloledb;database= library name; uid= user name; pwd= password; "
Read the table name in the SQL Server library:
Set Rs=conn.openschema (20)
While not Rs. Eof
Response.Write ("Database name:" & RS (0) & "<br>")
Response.Write ("Owner:" & RS (1) & "<br>")
Response.Write ("Table name:" & RS (2) & "<br>")
Response.Write ("Type of Table:" & RS (3) & "<br>")
So, we know the table name, so let's take a look at how to manipulate the table's fields.
Suppose: There are tables in the database: [Things], fields in the table: Id,thingsname,thingstype
Get all field names for this table:
Set rs=server.createobject ("ADODB. Recordset ")
Sql= "SELECT * from [things] where 1<>1"
For I=0 to (J-1)
Response.Write ("First" & i+1 & "field Name:" & Rs. Fields (i). Name & "<br><br>")
OK, now we know how to get the name of the field.
If you want to do something about the value of the field you get, this is OK:
For example, if we want to delete the field thingstype in the table [things], we can
To write in this way:
Sql= "ALTER TABLE [things] DROP COLUMN thingstype"
For example, we want to add a field thingscolor, its type is varchar type, length is 20, and the default value is red, as follows:
Sql= "ALTER TABLE [things] ADD thingscolor VARCHAR () DEFAULT ' Red '
The basic operation of the above fields is implemented in the SQL language, in the ASP, through the SQL language, we have sufficient permissions to complete
More database operations, such as create tables, delete tables with drop, etc.
Finally, I talents, this article certainly will have the mistake place, also hoped everybody criticizes.
Also hope that everyone in the csdn text to me to discuss together, thank you!
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to firstname.lastname@example.org. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
and provide relevant evidence. A staff member will contact you within 5 working days.