1. Por favor cree un nombre de base de datos en SQLServer: casa y ejecute el siguiente guión en casa
IfExists (seleccione*FromSySObjectswhereId = Object_id (n´ [DBO]. [Ciudad] ´) AndObjectProperty (ID, N´isusertable´) = 1)
Droptable [DBO]. [Ciudad]
IR
IfExists (seleccione*FromSySObjectswhereId = Object_id (n´ [dbo]. [área] ´) andobjectProperty (id, n´isusertable´) = 1)
Droptable [DBO]. [Área]
IR
Creatable [dbo]. [Ciudad] (
[id] [int] identidad (1,1) nonull,
[nombre] [nvarchar] (10) nulo
) En [primario]
IR
Creatable [dbo]. [Área] (
[id] [int] identidad (1,1) nonull,
[Cityid] [int] nulo,
[nombre] [nvarchar] (20) nulo
) En [primario]
IR
InsertInTocity (ID, nombre) Valores (1, "Guangzhou")
InsertInTocity (ID, nombre) Valores (2, "Shanghai")
InsertInTocity (ID, nombre) Valores (3, "Beijing")
InsertInToarea (ID, CityID, Nombre) Valores (1,1, "Tianhe")
InsertInToarea (ID, CityID, Nombre) Valores (2,1, "Cloud White")
InsertInToarea (ID, CityID, Nombre) Valores (3,2, "Hongkou")
InsertInToarea (ID, CityID, Nombre) Valores (4,2, "Baoshan")
InsertInToarea (ID, CityID, Nombre) Valores (5,2, "Jing'an")
InsertInToarea (ID, CityID, Nombre) Valores (6,3, "Haidian")
InsertInToarea (ID, CityID, Nombre) Valores (7,3, "Chaoyang")
2. Crea un archivo
Crear archivo CityData.asp
<%@Idioma = vBscript%>
<%Rsdispatch%>
<Scriptrunat = serverlanguage = javaScript>
<!-#includeVirtual = "/_ scriptLibrary/rs.asp"->
<!-#includeVirtual = "/jsconn.asp"->
functionDescription ()
{
this.getAaAsArray = dogetData;
}
public_Description = NewDescription ();
functionDogetData (CityID)
{
Varsql, RST, StrText, Conn, I, J
conn = newActivexObject ("ADODB.Connection");
conn.connectionString = connstr;
Conn.ConnectionTimeOut = 30;