<% @ Language = jscript %> <% function JScriptDatabaseRead() { var c, r, tv, phone, strOut = ""; var noElectricity, noTelevision, noTelephone = false; var CountryID = Request.QueryString("ID"); var sql_electricity = 'SELECT Country, City, Volts, System, Other_system, Hz, Stability, Amps, Plugs, Comment FROM Electricity WHERE ID = "' + CountryID + '";'; var sql_tv = 'SELECT Country, Television, Digital, Comment FROM Television WHERE ID = "' + CountryID + '";'; var sql_phone = 'SELECT Country, Plug, Mobile, Comment FROM Telephone WHERE ID = "' + CountryID + '";'; var cnstr = ""; /* Regular expressions to extract data to create links */ var linkPattern = /(\w+)/g; var fullPattern = /(\(\w+\)|\(\w+|\w+\)|\w+)/g; /* Make a constant with Ctrl + LineFeed chars. */ var vbCrLf = String.fromCharCode( 13, 10 ); cnstr+= "Provider=Microsoft.Jet.OLEDB.4.0;"; cnstr+= "Data Source=" + Server.Mappath("../db/Database.mdb"); /* Create database connection */ c = new ActiveXObject("ADODB.Connection"); c.Open(cnstr); //c.Open( Application("dbConn"), Application("dbUsr"), Application("dbPass") ); r = c.Execute(sql_electricity); try { /* Read data from database */ var Country = r(0); var City = r(1); var Volts = new String(r(2)); var System = new String(r(3)); var Other_system = new String(r(4)); var Hz = new String(r(5)); var Stability = new String(r(6)); var Amps = new String(r(7)); var Plugs = new String(r(8)); var Comment = new String(r(9)); if ((Volts == "0") || (Volts == "null")) {Volts = "";} else {Volts = Volts + " V";} if ((Other_system == "0") || (Other_system == "null")) {Other_system = "";} else {Other_system = " & " + Other_system;} if ((System == "0") || (System == "null")) {System = "";} else {Other_system = Other_system + " V";} if ((Hz == "0") || (Hz == "null")) {Hz = "";} if ((Stability == "0") || (Stability == "null")) {Stability = "";} if ((Amps == "0") || (Amps == "null")) {Amps = "";} else {Amps = Amps + " A";} if ((Plugs == "0") || (Plugs == "null")) {Plugs = "";} else { var plugLinkList = Plugs.match(linkPattern); var plugFullList = Plugs.match(fullPattern); Plugs = ""; for ( i = 0; i < (plugFullList.length - 1); i++) { Plugs += '' + plugFullList[i] + ', ';} Plugs += '' + plugFullList[(plugFullList.length - 1)] + ''; } if ((Comment == "0") || (Comment == "null")) {Comment = "";} /* Electricity table. Put data in string */ strOut+= "

" + Country + "

" + vbCrLf; strOut+= '' + vbCrLf; strOut+= '' + vbCrLf; strOut+= '' + vbCrLf; strOut+= "" + vbCrLf; strOut+= "" + vbCrLf; strOut+= "" + vbCrLf; strOut+= "" + vbCrLf; strOut+= "" + vbCrLf; strOut+= '' + vbCrLf; strOut+= "
Electricity
Nominal system voltages' + System + Other_system +'Frequency' + Hz + ' Hz
Nominal voltage at outlet" + Volts +"Stable" + Stability + "
Amperes at outlet" + Amps + "Outlets" + Plugs + "
 
' + Comment + '
" + vbCrLf; } catch(e) {noElectricity = true;} /* Close electricity database. */ r.Close(); /* Television. Fetch data from database */ tv = c.Execute(sql_tv); try { var TVcountry = new String(tv(0)); var AnalogueTV = new String(tv(1)); var DigitalTV = new String(tv(2)); var TVcomment = new String(tv(3)); if (AnalogueTV == "null") {AnalogueTV = "";} if (DigitalTV == "null") {DigitalTV = "";} if (TVcomment == "null") {TVcomment = "";} /* Print heading if it is a record without electric information */ if (noElectricity == true) {strOut+= "

" + TVcountry + "

" + vbCrLf;} else {strOut+= "

";} /* Television table. */ strOut+= '' + vbCrLf; strOut+= '' + vbCrLf; strOut+= '' + vbCrLf; strOut+= "" + vbCrLf; strOut+= '' + vbCrLf; strOut+= "
Television
Analogue system(s)' + AnalogueTV +'Digital system(s)' + DigitalTV + '
 
' + TVcomment + '
" + vbCrLf; } catch(e) {noTelevision = true;} /* Close television database. */ tv.close(); /* Telephone. Fetch data from database */ phone = c.Execute(sql_phone); try { var PhoneCountry = new String(phone(0)); var phonePlug = new String(phone(1)); var mobileSystem = new String(phone(2)); var phoneComment = new String(phone(3)); if (phonePlug == "null") {phonePlug = "";} if (mobileSystem == "null") {mobileSystem = "";} if (phoneComment == "null") {phoneComment = "";} /* If it is a record without Electricity and Television */ if (noElectricity && noTelevision) {strOut+= "

" + PhoneCountry + "

" + vbCrLf;} else {strOut+= "

";} /* Telephone table. */ strOut+= '' + vbCrLf; strOut+= '' + vbCrLf; strOut+= '' + vbCrLf; strOut+= "" + vbCrLf; strOut+= '' + vbCrLf; strOut+= "
Telephone
Phone plug(s)' + phonePlug + '
Mobile System(s)' + mobileSystem + '
 
' + phoneComment + '
" + vbCrLf; } catch(e) {noTelephone = true;} /* Close telephone database. */ phone.close(); /* Close Database */ c.Close(); /* Exit the function and return the data. */ return(strOut); } %> Global-Electron
<% // call function and write the results to the browser. Response.Write ( JScriptDatabaseRead() ); %>