国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

javascript asp教程創(chuàng)建數(shù)據(jù)庫連接

2024-05-04 10:58:21
字體:
供稿:網(wǎng)友

While this section is devoted to ASP database utilization, it very important to remember that this web site is not intended to be a thorough ASP resource. Remember, the focus of this site is strictly limited to how to use JavaScript as your primary scripting language for ASP.

You'll see how to construct connection strings in JavaScript, use JavaScript loops to manipulate recordsets, convert the JavaScript Date Object into a format that databases can accept, and to some extent you'll see how to make SQL statements in JavaScript.

You can find a lot of good resources on database utilization. Those resources, coupled with the next four lessons, will be everything you need to write ASP JavaScript database applications.

The Connection Object:

The connection object is the link between the database and your ASP script. Remember, it's a created or instanciated object, so we can have two or more instances of Connection on one page. Connection has eight (8) methods, eleven (11) properties, nine (9) events, and finally it has two (2) properties. We will discuss three of the methods, one of the properties, and then we will forego the rest.

There are four common connections. 1) MDL 2) DSN 3) ODBC 4) OLE-DB. MDL stands for Microsoft Data Link. Don't use it. Also, please don't use a DSN; it's slow and outdated and nobody recommends it. ODBC is better, but it's not the best. The recommended connection type is OLE-DB. That's the type of connection you'll see demonstrated below.

Get Started:

Below is the script for Lesson 16. Don't try to understand it yet. We will slowly pick this thing apart down below.

<%@LANGUAGE="JavaScript"%><!-- METADATA TYPE="typelib" FILE="C:/Program Files/Common Files/System/ado/msado15.dll" --><HTML><BODY><%var myConnect = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="; myConnect += Server.MapPath("http://");myConnect += "http://GlobalScripts//htmlColor.mdb;";var ConnectObj = Server.CreateObject("ADODB.Connection");var RS = Server.CreateObject("ADODB.Recordset");var sql="SELECT ID, colorName, hexValue FROM colorChart;";ConnectObj.Open (myConnect);RS.Open(sql,ConnectObj,adOpenForwardOnly,adLockReadOnly,adCmdText);Response.Write("<TABLE BORDER=/"1/" CELLSPACING=/"0/">/r");Response.Write("<TR><TH>ID</TH><TH>colorName</TH>");Response.Write("<TH>hexValue</TH></TR>/r");while (!RS.EOF)	{	Response.Write("<TR><TD>" +RS("ID")+ "</TD><TD BGCOLOR=/"#");	Response.Write( RS("hexValue")+ "/">" + RS("colorName") );	Response.Write("</TD><TD>" +RS("hexValue")+ "</TD></TR>/r");	RS.MoveNext();	}Response.Write("</TABLE>/r");RS.Close();ConnectObj.Close();RS = null;ConnectObj = null;%></BODY></HTML>

Click Here to run the script in a new window.

Connection String:

This is by no means the most sophisticated database application ever built, but it will demonstrate everything we need to do. Let's start by looking at the connection string reprinted below.

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 福贡县| 诏安县| 马尔康县| 宜丰县| 汉中市| 砚山县| 张家港市| 芜湖市| 黄平县| 乃东县| 任丘市| 准格尔旗| 上栗县| 安福县| 永和县| 洮南市| 灯塔市| 阿合奇县| 肇源县| 延川县| 凯里市| 繁峙县| 增城市| 个旧市| 措勤县| 香河县| 仁怀市| 迭部县| 咸阳市| 新乐市| 乌拉特前旗| 北海市| 沈丘县| 木兰县| 舟曲县| 九江市| 海林市| 循化| 高要市| 锦屏县| 寿光市|