⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sql server基本操作-10.htm

📁 微软数据库开发梦工场多媒体教学-sql server篇.rar,是多媒体教学的
💻 HTM
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0073)http://wwwb.pconline.com.cn/pcedu/rookie/program/doc/database/10605_1.htm -->
<HTML><HEAD><TITLE>PConline-> 网络学院</TITLE><!-- #BeginTemplate "/Templates/rookie-doc.dwt" -->
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<STYLE type=text/css></STYLE>
<LINK href="SQL SERVER基本操作-10.files/text.css" rel=stylesheet>
<SCRIPT language=JavaScript><!--function MM_swapImgRestore() { //v3.0  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;}function MM_preloadImages() { //v3.0  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}}function MM_swapImage() { //v3.0  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}}//--></SCRIPT>

<META content="MSHTML 6.00.2716.2200" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 
onload="MM_preloadImages('/images/lefton.gif','/images/topon.gif')" 
marginheight="0"><A name=top></A>
<SCRIPT language=JavaScript src="SQL SERVER基本操作-10.files/top.js"></SCRIPT>

<TABLE cellSpacing=0 cellPadding=0 width=760 align=center border=0>
  <TBODY>
  <TR>
    <TD width=194 height=56><A href="http://www.pconline.com.cn/"><IMG 
      height=35 src="SQL SERVER基本操作-10.files/pconlinelogo.gif" width=162 
      vspace=10 border=0></A></TD>
    <TD width=406 height=56>
      <SCRIPT language=JavaScript 
      src="SQL SERVER基本操作-10.files/rookie_ad.js"></SCRIPT>
    </TD>
    <TD align=right width=158 height=56>
      <SCRIPT language=JavaScript 
      src="SQL SERVER基本操作-10.files/rookie_ad1.js"></SCRIPT>
    </TD>
    <TD align=right width=2 height=56>&nbsp;</TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=760 align=center border=0>
  <TBODY>
  <TR vAlign=bottom>
    <TD width=172 rowSpan=2><IMG height=32 
      src="SQL SERVER基本操作-10.files/pcedu_lo.gif" width=172 border=0></TD>
    <TD height=30 rowSpan=2>
      <TABLE cellSpacing=0 cellPadding=0 width=588 bgColor=#ffa000 
      background="SQL SERVER基本操作-10.files/e_menu2.gif" border=0>
        <TBODY>
        <TR vAlign=bottom>
          <TD height=17>
            <SCRIPT language=JavaScript 
            src="SQL SERVER基本操作-10.files/title_rookie.js"></SCRIPT>
          </TD></TR></TBODY></TABLE></TD></TR>
  <TR></TR>
  <TR bgColor=#303880>
    <TD vAlign=bottom colSpan=2 height=1><IMG height=1 
      src="SQL SERVER基本操作-10.files/blank.gif" width=1></TD></TR>
  <TR>
    <TD vAlign=bottom colSpan=2 height=5><IMG height=5 
      src="SQL SERVER基本操作-10.files/blank.gif" width=1></TD></TR></TBODY></TABLE>
<TABLE height=614 cellSpacing=0 cellPadding=0 width=760 align=center>
  <TBODY>
  <TR>
    <TD vAlign=top width=170 height=616 rowSpan=2>
      <TABLE height="100%" cellSpacing=1 width=170 bgColor=#000000 border=0>
        <TBODY>
        <TR bgColor=#f8f8d2>
          <TD vAlign=top width="100%" height=307>
            <SCRIPT language=JavaScript 
            src="SQL SERVER基本操作-10.files/left_rookie.js"></SCRIPT>
          </TD></TR></TBODY></TABLE></TD>
    <TD width=8 height=308><IMG height=1 
      src="SQL SERVER基本操作-10.files/blank.gif" width=1></TD>
    <TD vAlign=top width=582 height=444>
      <TABLE height=1 cellSpacing=0 cellPadding=0 width=582 
      background="SQL SERVER基本操作-10.files/line5.gif" border=0>
        <TBODY>
        <TR>
          <TD height=1></TD></TR></TBODY></TABLE><!-- #BeginEditable "content" -->
      <TABLE class=article cellSpacing=8 cellPadding=0 width=582 
      background="SQL SERVER基本操作-10.files/bg6.gif" border=0>
        <TBODY>
        <TR>
          <TD vAlign=top>
            <TABLE cellSpacing=8 cellPadding=0 width="100%" 
            background="SQL SERVER基本操作-10.files/point.gif" border=0>
              <TBODY>
              <TR>
                <TD colSpan=3 height=4></TD></TR>
              <TR>
                <TD colSpan=3 height=22>
                  <DIV class=title align=center>网络数据库设计入门(十七)</DIV></TD></TR>
              <TR vAlign=bottom>
                <TD width=90 height=18>
                  <DIV class=gray align=right>&nbsp;&nbsp;&nbsp;&nbsp;</DIV></TD>
                <TD>
                  <DIV class=gray align=center><FONT color=#666666>作者:心如止水 
                  咖啡豆/太平洋网络学院</FONT></DIV></TD>
                <TD width=90>
                  <DIV class=gray align=right><A 
                  href="mailto:tntst@pconline.com.cn">[责编:爆破手]</A></DIV></TD></TR>
              <TR vAlign=bottom>
                <TD colSpan=3 height=0></TD></TR></TBODY></TABLE>
            <P class=article align=center><B>ODBC与ADO对象</B></P>
            <DIV style="LAYOUT-GRID:  15.6pt none">
            <P class=article>(1)创建数据库源名,即创建和配置ODBC数据源,该步骤在上一节我们已详细讲述。</P>
            <P class=article>(2)创建数据库链接:</P>
            <P class=article>ASP文件中如果要访问数据,必须首先创建与数据库的链接,其语法如下:</P>
            <P class=article>   Set Conn = Server CreateObject 
            (“ADOBD.CONNECTION”)</P>
            <P class=article>这条语句创建了链接对象Conn,接下来:</P>
            <P class=article>   Conn.Open “dsn_name”,“username”,“password”</P>
            <P 
            class=article>这条语句打开链接,用到了DSN,本例中DSN名为“dsn_name”。其后的两个参数分别是访问数据库的用户名和口令,为可选参数。</P>
            <P class=article>如我们前边对系统DSN的设置,这一段代码可以写为:</P>
            <P class=article>访问Access数据库系统DSN:</P>
            <P class=article>Set Conn = Server CreateObject 
            (“ADOBD.CONNECTION”)</P>
            <P class=article>Conn.Open “test_dsn”</P>
            <P class=article>访问SQL Server数据库系统DSN:</P>
            <P class=article>Set Conn = Server CreateObject 
            (“ADOBD.CONNECTION”)</P>
            <P class=article>Conn.Open “test_dsn_sql”,“sa”,“passwd”</P>
            <P class=article>其中的“sa”为访问SQL 
            Server数据库的帐号,“passwd”为该帐号的访问口令,具体的内容创建数据库时的设定。</P>
            <P 
            class=article>在ADO中还可以不通过ODBC而直接与Access数据相连,这种方法在个人主页中大量使用(因为其用户无法进行服务器ODBC设置操作),我们这里只简单提一下方法:</P>
            <P class=article>Connection.Open “driver = {Microsoft Access Driver 
            (*.mdb) };</P>
            <P class=article>dbq=c:\test.mdb”</P>
            <P class=article>(3)创建数据对象:</P>
            <P class=article>RecordSet保存的是数据库命令结果集,并标有一个当前记录。以下是创建方法:</P>
            <P class=article>  Set RecordSet = Conn.Execute(sqtStr)</P>
            <P 
            class=article>这条语句创建并打开了对象RecordSet,其中Conn是先前创建的链接对象,SqlStr是一个串,代表一条标准的SQL语句,例如:</P>
            <P class=article>  &nbsp; SqlStr = “SELECT * FROM authors”</P>
            <P class=article>Set RecordSet=Conn.Execute (SqlStr)</P>
            <P class=article>这条语句执行后,对象RecordSet中就保存了表authors中的所有记录。</P>
            <P class=article>(4) 操作数据库:</P>
            <P 
            class=article>Execute方法的参数是一个标准的SQL语句串,所以我们可以利用它方便地执行数据插入、修改、删除等操作,例如:</P>
            <P class=article>  qlStr = "DELETE FROM authors"</P>
            <P class=article>  &nbsp; Conn.Execute (SqlStr)  /执行删除操作</P>
            <P class=article>SqlStr = "UPDATE authors SET salary=3 WHERE id= 
            ‘FZ0001’"</P>
            <P class=article>Conn.Execute (SqlStr)  /执行修改操作</P>
            <P class=article>(5) 关闭数据对象和链接:</P>
            <P 
            class=article>在使用了ADO对象之后,一定要记住关闭它,因为它使用了服务器的资源,如果不释放的话将导致服务器资源浪费并影响服务器性能。通过调用方法close实现关闭,然后再释放它,例如:</P>
            <P class=article>Conn.Close</P></DIV>
            <P class=article align=center><A 
            href="http://wwwb.pconline.com.cn/pcedu/rookie/program/doc/database/10605.htm">[上一页]</A></P></TD></TR>
        <TR bgColor=#ff6600>
          <TD height=1></TD></TR>
        <TR>
          <TD>
            <TABLE cellSpacing=0 cellPadding=0 width="100%" 
            background="SQL SERVER基本操作-10.files/point.gif" border=0>
              <TBODY>
              <TR>
                <TD colSpan=2>
                  <P class=basicfont align=center><BR>如果您有什么疑问或看法请到 <A 
                  class=blue 
                  href="http://home.pconline.com.cn/cgi-bin/newbbs/bbs_login.cgi?loginname=guest&amp;loginpasswd=guest" 
                  target=_blank>精彩论坛</A> 发表意见<BR></P>
                  <P class=basicfont align=center><FONT color=#ff0000><B 
                  class=article>未经同意 不得转载</B></FONT><BR></P>
                  <P class=basicfont align=center><SPAN class=basicfont><A 
                  onmouseover="MM_swapImage('image3','','/images/lefton.gif',1)" 
                  onmouseout=MM_swapImgRestore() 
                  href="javascript:history.back(-1)"><IMG height=22 alt=返回 
                  src="SQL SERVER基本操作-10.files/LEFTOFF.gif" width=19 border=0 
                  name=image3></A> <A 
                  onmouseover="MM_swapImage('image2','','/images/topon.gif',1)" 
                  onmouseout=MM_swapImgRestore() 
                  href="http://wwwb.pconline.com.cn/pcedu/rookie/program/doc/database/10605_1.htm#top"><IMG 
                  height=22 alt=页首 src="SQL SERVER基本操作-10.files/TOPOFF.gif" 
                  width=22 border=0 
            name=image2></A></SPAN></P></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><!-- #EndEditable -->
      <TABLE height=1 cellSpacing=0 cellPadding=0 width=582 
      background="SQL SERVER基本操作-10.files/line5.gif" border=0>
        <TBODY>
        <TR>
          <TD height=1></TD></TR></TBODY></TABLE><IMG height=24 
      src="G:\数据库教程\SQL Server基本操作\SQL SERVER基本操作-10.files\blank(1).gif" 
      width=1><BR>
      <SCRIPT src="SQL SERVER基本操作-10.files/hotfiles.js"></SCRIPT>
    </TD></TR></TBODY></TABLE>
<HR width=760 noShade SIZE=2>

<P align=center>
<SCRIPT language=JavaScript 
src="SQL SERVER基本操作-10.files/title_edu.js"></SCRIPT>
<BR><BR>版权所有&copy;2000 太平洋电脑网<BR><FONT face="Arial, Helvetica, sans-serif">
<SCRIPT>document.write("<a href=http://best.netease.com/cgi-bin/view/viewbasic.cgi?exp target=_blank><img src=http://best.netease.com/cgi-bin/log.cgi?user=exp&refer="+escape(document.referrer)+"&cur="+escape(document.URL)+" border=0 alt='网易中文排行榜' width=1 height=1></a>");</SCRIPT>
<A href="mailto:webmaster@pconline.com.cn">mailto:webmaster@pconline.com.cn</A>
<SCRIPT language="">document.write("<a href=http://best.netease.com/cgi-bin/view/viewbasic.cgi?pconline1 target=_blank><img src=http://best.netease.com/cgi-bin/log.cgi?user=pconline1&refer="+escape(document.referrer)+"&cur="+escape(document.URL)+" border=0 width=1 height=1 ></a>");</SCRIPT>

<SCRIPT language="">document.write("<a href=http://count.pconline.com.cn/admin/index.php target=_blank><img src=http://count.pconline.com.cn/count.php?user=pcedu&refer="+escape(document.referrer)+" border=0 width=0 height=0 alt='' ></a>");</SCRIPT>
</FONT></P><!-- #EndTemplate --></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -