ASP gets database table names, field names, and some operations to fields

xiaoxiao2021-03-06  18

Recently, I saw a lot of netizens asked how many netizens asked how to get database table names, field names, and how to delete fields, and add this article. I am more familiar with SQL Server, so SQL Server is column: <% set conn = server.createObject ("adodb.connection") conn.open "server = IP address; provider = SQLOLEDB; Database = library name; UID = User name ; PWD = password; "%> Name name in the SQL Server library: <% set = conn.openschema (20) While NOT RS.EOF response.write (" The database name: "& rs (0) &" < BR> ") Response.write (" Owner: ") Response.write (" Table Name: "& RS (2) &"
") Response.write "Type of Table:" & RS (3) & "
") rs.movenext Wend%> This, we know the table name, now let's take a look at how to operate on the table. Suppose: [Things], the field in the database is: ID, thingsname, ThingsType Get all the field names of the table: <% DIM I, J, SQL SET RS = Server.createObject ("AdoDb.Recordset" ) SQL = "Select * from [things] where 1 <> 1" RS.Open SQL, CONN, 1, 1 J = r.fields.count for i = 0 to (J-1) Response.write ("" "" & i 1 & "field name:" & rs.Fields (i) .Name & "

") Next%> well, now we understand how to obtain a field name.

转载请注明原文地址:https://www.9cbs.com/read-42330.html

New Post(0)