﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-海上月明-随笔分类-DataBase</title><link>http://www.blogjava.net/pts/category/19683.html</link><description>editer by sun</description><language>zh-cn</language><lastBuildDate>Tue, 01 Apr 2008 22:22:15 GMT</lastBuildDate><pubDate>Tue, 01 Apr 2008 22:22:15 GMT</pubDate><ttl>60</ttl><item><title>mysql的insert/replace/update/delete &amp; insert,update,delete多表操作</title><link>http://www.blogjava.net/pts/archive/2008/04/01/190186.html</link><dc:creator>pts</dc:creator><author>pts</author><pubDate>Tue, 01 Apr 2008 12:02:00 GMT</pubDate><guid>http://www.blogjava.net/pts/archive/2008/04/01/190186.html</guid><wfw:comment>http://www.blogjava.net/pts/comments/190186.html</wfw:comment><comments>http://www.blogjava.net/pts/archive/2008/04/01/190186.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/pts/comments/commentRss/190186.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/pts/services/trackbacks/190186.html</trackback:ping><description><![CDATA[<big>mysql的insert/replace/update/delete &amp; insert,update,delete多表操作</big><br />
<p class="xspace-smalltxt">2008-03-28 15:44:10 from <a href="http://www.phpchina.com/html/40/52440_itemid_30622.html"><strong>WriteDream</strong></a>     </p>
INSERT和REPLACE语句的功能都是向表中插入新的数据。这两条语句的语法类似。它们的主要区别是如何处理重复的数据。
<p style="text-indent: 2em;">1. INSERT的一般用法</p>
<p style="text-indent: 2em;"><a ō nclick="javascrīpt:tagshow(event, 'MySQL');" href="http://www.phpchina.com/html/40/javascr%C4%ABpt:;" target="_self"><u><strong>MySQL</strong></u></a>中的INSERT语句和标准的INSERT不太一样，在标准的SQL语句中，一次插入一条记录的INSERT语句只有一种形式。</p>
<p style="text-indent: 2em;">INSERT INTO tablename(列名&#8230;) VALUES(列值);</p>
<p style="text-indent: 2em;">而在MySQL中还有另外一种形式。</p>
<p style="text-indent: 2em;">INSERT INTO tablename SET column_name1 = value1, column_name2 = value2，&#8230;;</p>
<p style="text-indent: 2em;">第一种<a ō nclick="javascrīpt:tagshow(event, '%B7%BD%B7%A8');" href="http://www.phpchina.com/html/40/javascr%C4%ABpt:;" target="_self"><u><strong>方法</strong></u></a>将列名和列值分开了，在使用时，列名必须和列值的数一致。如下面的语句向users表中插入了一条记录：</p>
<p style="text-indent: 2em;">INSERT INTO users(id, name, age) VALUES(123, '姚明', 25);</p>
<p style="text-indent: 2em;">第二种方法允许列名和列值成对出现和使用，如下面的语句将产生中样的效果。</p>
<p style="text-indent: 2em;">INSERT INTO users SET id = 123, name = '姚明', age = 25;</p>
<p style="text-indent: 2em;">如果使用了SET方式，必须至少为一列赋值。如果某一个字段使用了省缺值（如默认或自增值），这两种方法都可以省略这些字段。如id字段上使用了自增值，上面两条语句可以写成如下形式：</p>
<p style="text-indent: 2em;">INSERT INTO users (name, age) VALUES('姚明',25);</p>
<p style="text-indent: 2em;">INSERT INTO uses SET name = '姚明', age = 25;</p>
<p style="text-indent: 2em;">MySQL在VALUES上也做了些变化。如果VALUES中什么都不写，那MySQL将使用表中每一列的默认值来插入新记录。</p>
<p style="text-indent: 2em;">INSERT INTO users () VALUES();</p>
<p style="text-indent: 2em;">如果表名后什么都不写，就表示向表中所有的字段赋值。使用这种方式，不仅在VALUES中的值要和列数一致，而且顺序不能颠倒。 INSERT INTO users VALUES(123, '姚明', 25);</p>
<p style="text-indent: 2em;">如果将INSERT语句写成如下形式MySQL将会报错。</p>
<p style="text-indent: 2em;">INSERT INTO users VALUES('姚明',25);</p>
<p style="text-indent: 2em;">2. 使用INSERT插入多条记录</p>
<p style="text-indent: 2em;">看
到这个标题也许大家会问，这有什么好说的，调用多次INSERT语句不就可以插入多条记录
了吗！但使用这种方法要增加服务器的负荷，因为，执行每一次SQL服务器都要同样对SQL进行分析、优化等操作。幸好MySQL提供了另一种解决方案，就
是使用一条INSERT语句来插入多条记录。这并不是标准的SQL语法，因此只能在MySQL中使用。</p>
<p style="text-indent: 2em;">INSERT INTO users(name, age)</p>
<p style="text-indent: 2em;">VALUES('姚明', 25), ('比尔.盖茨', 50), ('火星人', 600);</p>
<p style="text-indent: 2em;">上面的INSERT 语句向users表中连续插入了3条记录。值得注意的是，上面的INSERT语句中的VALUES后必须每一条记录的值放到一对(&#8230;)中，中间使用","分割。假设有一个表table1</p>
<p style="text-indent: 2em;">CREATE TABLE table1(n INT)；</p>
<p style="text-indent: 2em;">如果要向table1中插入5条记录，下面写法是错误的：</p>
<p style="text-indent: 2em;">INSERT INTO table1 (i) VALUES(1,2,3,4,5);</p>
<p style="text-indent: 2em;">MySQL将会抛出下面的错误</p>
<p style="text-indent: 2em;">ERROR 1136: Column count doesn't match value count at row 1</p>
<p style="text-indent: 2em;">而正确的写法应该是这样：</p>
<p style="text-indent: 2em;">INSERT INTO t able1(i) VALUES(1),(2),(3),(4),(5);</p>
<p style="text-indent: 2em;">当然，这种写法也可以省略列名，这样每一对括号里的值的数目必须一致，而且这个数目必须和列数一致。如：</p>
<p style="text-indent: 2em;">INSERT INTO t able1 VALUES(1),(2),(3),(4),(5);</p>
<p style="text-indent: 2em;">3. REPLACE语句</p>
<p style="text-indent: 2em;">我们在使用<a ō nclick="javascrīpt:tagshow(event, '%CA%FD%BE%DD%BF%E2');" href="http://www.phpchina.com/html/40/javascr%C4%ABpt:;" target="_self"><u><strong>数据库</strong></u></a>时
可能会经常遇到这种情况。如果一个表在一个字段上建立了唯一索引，当我们再向这个表中使用已经存在的键值插入一条记录，那将会抛出一个主键冲突的错误。当
然，我们可能想用新记录的值来覆盖原来的记录值。如果使用传统的做法，必须先使用DELETE语句删除原先的记录，然后再使用INSERT插入新的记录。
而在MySQL中为我们提供了一种新的解决方案，这就是REPLACE语句。使用REPLACE插入一条记录时，如果不重复，REPLACE就和
INSERT的功能一样，如果有重复记录，REPLACE就使用新记录的值来替换原来的记录值。</p>
<p style="text-indent: 2em;">使用REPLACE的最大好处就是可以将DELETE和INSERT合二为一，形成一个原子操作。这样就可以不必考虑在同时使用DELETE和INSERT时添加事务等复杂操作了。</p>
<p style="text-indent: 2em;">在使用REPLACE时，表中必须有唯一索引，而且这个索引所在的字段不能允许空值，否则REPLACE就和INSERT完全一样的。</p>
<p style="text-indent: 2em;">在
执行REPLACE后，系统返回了所影响的行数，如果返回1，说明在表中并没有重复的记
录，如果返回2，说明有一条重复记录，系统自动先调用了DELETE删除这条记录，然后再记录用INSERT来插入这条记录。如果返回的值大于2，那说明
有多个唯一索引，有多条记录被删除和插入。</p>
<p style="text-indent: 2em;">REPLACE的语法和INSERT非常的相似，如下面的REPLACE语句是插入或更新一条记录。</p>
<p style="text-indent: 2em;">REPLACE INTO users (id,name,age) VALUES(123, '赵本山', 50);</p>
<p style="text-indent: 2em;">插入多条记录：</p>
<p style="text-indent: 2em;">REPLACE INTO users(id, name, age)</p>
<p style="text-indent: 2em;">VALUES(123, '赵本山', 50), (134,'Mary',15);</p>
<p style="text-indent: 2em;">REPLACE也可以使用SET语句</p>
<p style="text-indent: 2em;">REPLACE INTO users SET id = 123, name = '赵本山', age = 50;</p>
<p style="text-indent: 2em;">上
面曾提到REPLACE可能影响3条以上的记录，这是因为在表中有超过一个的唯一索引。在
这种情况下，REPLACE将考虑每一个唯一索引，并对每一个索引对应的重复记录都删除，然后插入这条新记录。假设有一个table1表，有3个字段a,
b, c。它们都有一个唯一索引。</p>
<p style="text-indent: 2em;">CREATE TABLE table1(a INT NOT NULL UNIQUE,b INT NOT NULL UNIQUE,c INT NOT NULL UNIQUE);</p>
<p style="text-indent: 2em;">假设table1中已经有了3条记录</p>
<p style="text-indent: 2em;">a b c</p>
<p style="text-indent: 2em;">1 1 1</p>
<p style="text-indent: 2em;">2 2 2</p>
<p style="text-indent: 2em;">3 3 3 </p>
<p style="text-indent: 2em;">下面我们使用REPLACE语句向table1中插入一条记录。</p>
<p style="text-indent: 2em;">REPLACE INTO table1(a, b, c) VALUES(1,2,3);</p>
<p style="text-indent: 2em;">返回的结果如下</p>
<p style="text-indent: 2em;">Query OK, 4 rows affected (0.00 sec)</p>
<p style="text-indent: 2em;">在table1中的记录如下</p>
<p style="text-indent: 2em;">a b c</p>
<p style="text-indent: 2em;">1 2 3</p>
<p style="text-indent: 2em;">我们可以看到，REPLACE将原先的3条记录都删除了，然后将（1, 2, 3）插入。 </p>
<p style="text-indent: 2em;">二、UPDATE</p>
<p style="text-indent: 2em;">UPDATE的功能是更新表中的数据。这的语法和INSERT的第二种用法相似。必须提供表名以及SET表达式，在后面可以加WHERE以限制更新的记录范围。</p>
<p style="text-indent: 2em;">UPDATE table_anem SET column_name1 = value1, column_name2 = value2, ...</p>
<p style="text-indent: 2em;">WHERE ... ;</p>
<p style="text-indent: 2em;">如下面的语句将users表中id等于123的记录的age改为24</p>
<p style="text-indent: 2em;">UPDATE users SET age = 24 WHERE id = 123;</p>
<p style="text-indent: 2em;">同样，可以使用UPDATE更新多个字段的值 UPDATE users SET age = 24, name = 'Mike' WHERE id = 123;</p>
<p style="text-indent: 2em;">上面的UPDATE语句通过WHERE指定一个条件，否则，UPDATE将更新表中的所有记录的值。</p>
<p style="text-indent: 2em;">在
使用UPDATE更新记录时，如果被更新的字段的类型和所赋的值不匹配时，MySQL将这
个值转换为相应类型的值。如果这个字段是数值类型，而且所赋值超过了这个数据类型的最大范围，那么MySQL就将这个值转换为这个范围最大或最小值。如果
字符串太长，MySQL就将多余的字符串截去。如果设置非空字段为空，那么将这个字段设置为它们的默认值，数字的默认值是0，字符串的默认值是空串（不是
null，是""）。</p>
<p style="text-indent: 2em;">有两种情况UPDATE不会对影响表中的数据。</p>
<p style="text-indent: 2em;">1. 当WHERE中的条件在表中没有记录和它匹配时。</p>
<p style="text-indent: 2em;">2. 当我们将同样的值赋给某个字段时，如将字段abc赋为'123'，而abc的原值就是'123'。</p>
<p style="text-indent: 2em;">和INSERT、REPLACE一样，UPDATE也返回所更新的记录数。但这些记录数并不包括满足WHERE条件的，但却未被更新的记录。如下同的UPDATE语句就未更新任何记录。</p>
<p style="text-indent: 2em;">UPDATE users SET age = 30 WHERE id = 12;</p>
<p style="text-indent: 2em;">Query OK, 0 rows affected (0.00 sec)</p>
<p style="text-indent: 2em;">需要注意的时，如果一个字段的类型是TIMESTAMP，那么这个字段在其它字段更新时自动更新。</p>
<p style="text-indent: 2em;">在有些时候我们需要得到UPDATE所选择的行数，而不是被更新的行数。我们可以通过一些API来达到这个目的。如MySQL提供的C API提供了一个选项可以得到你想要的记录数。而MySQL的JDBC驱动得到的默认记录数也是匹配的记录数。</p>
<p style="text-indent: 2em;">UPDATE和REPLACE基本类似，但是它们之间有两点不同。</p>
<p style="text-indent: 2em;">1. UPDATE在没有匹配记录时什么都不做，而REPLACE在有重复记录时更新，在没有重复记录时插入。</p>
<p style="text-indent: 2em;">2. UPDATE可以选择性地更新记录的一部分字段。而REPLACE在发现有重复记录时就将这条记录彻底删除，再插入新的记录。也就是说，将所有的字段都更新了。</p>
<p style="text-indent: 2em;">三、DELETE和TRUNCATE TABLE</p>
<p style="text-indent: 2em;">在MySQL中有两种方法可以删除数据，一种是DELETE语句，另一种是TRUNCATE TABLE语句。DELETE语句可以通过WHERE对要删除的记录进行选择。而使用TRUNCATE TABLE将删除表中的所有记录。因此，DELETE语句更灵活。</p>
<p style="text-indent: 2em;">如果要清空表中的所有记录，可以使用下面的两种方法：</p>
<p style="text-indent: 2em;">DELETE FROM table1</p>
<p style="text-indent: 2em;">TRUNCATE TABLE table1</p>
<p style="text-indent: 2em;">其中第二条记录中的TABLE是可选的。</p>
<p style="text-indent: 2em;">如果要删除表中的部分记录，只能使用DELETE语句。</p>
<p style="text-indent: 2em;">DELETE FROM table1 WHERE ...;</p>
<p style="text-indent: 2em;">如果DELETE不加WHERE子句，那么它和TRUNCATE TABLE是一样的，但它们有一点不同，那就是DELETE可以返回被删除的记录数，而TRUNCATE TABLE返回的是0。</p>
<p style="text-indent: 2em;">如果一个表中有自增字段，使用TRUNCATE TABLE和没有WHERE子句的DELETE删除所有记录后，这个自增字段将起始值恢复成1.如果你不想这样做的话，可以在DELETE语句中加上永真的WHERE，如WHERE 1或WHERE true。</p>
<p style="text-indent: 2em;">DELETE FROM table1 WHERE 1;</p>
<p style="text-indent: 2em;">上面的语句在执行时将扫描每一条记录。但它并不比较，因为这个WHERE条件永远为true。这样做虽然可以保持自增的最大值，但由于它是扫描了所有的记录，因此，它的执行成本要比没有WHERE子句的DELETE大得多。</p>
<p style="text-indent: 2em;">DELETE和TRUNCATE TABLE的最大区别是DELETE可以通过WHERE语句选择要删除的记录。但执行得速度不快。而且还可以返回被删除的记录数。而TRUNCATE TABLE无法删除指定的记录，而且不能返回被删除的记录。但它执行得非常快。</p>
<p style="text-indent: 2em;">和
标准的SQL语句不同，DELETE支持ORDER
BY和LIMIT子句，通过这两个子句，我们可以更好地控制要删除的记录。如当我们只想删除WHERE子句过滤出来的记录的一部分，可以使用LIMIB，
如果要删除后几条记录，可以通过ORDER
BY和LIMIT配合使用。假设我们要删除users表中name等于"Mike"的前6条记录。可以使用如下的DELETE语句：</p>
<p style="text-indent: 2em;">DELETE FROM users WHERE name = 'Mike' LIMIT 6;</p>
<p style="text-indent: 2em;">一般MySQL并不确定删除的这6条记录是哪6条，为了更保险，我们可以使用ORDER BY对记录进行排序。</p>
<p style="text-indent: 2em;">DELETE FROM users WHERE name = 'Mike' ORDER BY id DESC LIMIT 6;</p>
<p style="text-indent: 2em;">将B表查询的数据插入A表：</p>
<p style="text-indent: 2em;">insert into A&nbsp; select 。。。from B where。。。</p>
<p style="text-indent: 2em;">or</p>
<p style="text-indent: 2em;">insert into A (。。。）select 。。。from B where。。。</p>
<p style="text-indent: 2em;">将B表的值更新到A表：</p>
<p style="text-indent: 2em;">update A set a = (select b from B where B.id = A.id) where exists(select 1 from B where id = A.id) and 。。。</p>
<p style="text-indent: 2em;">同时删除多表数据：</p>
<p style="text-indent: 2em;">delete A,B from A,B where A.id = B.id and 。。。</p>
<p style="text-indent: 2em;">or</p>
<p style="text-indent: 2em;">delete from A,B using A,B where A.id = B.id and 。。。</p>
<img src ="http://www.blogjava.net/pts/aggbug/190186.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/pts/" target="_blank">pts</a> 2008-04-01 20:02 <a href="http://www.blogjava.net/pts/archive/2008/04/01/190186.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>python中访问access的时间格式字段</title><link>http://www.blogjava.net/pts/archive/2008/03/13/185989.html</link><dc:creator>pts</dc:creator><author>pts</author><pubDate>Thu, 13 Mar 2008 04:16:00 GMT</pubDate><guid>http://www.blogjava.net/pts/archive/2008/03/13/185989.html</guid><wfw:comment>http://www.blogjava.net/pts/comments/185989.html</wfw:comment><comments>http://www.blogjava.net/pts/archive/2008/03/13/185989.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/pts/comments/commentRss/185989.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/pts/services/trackbacks/185989.html</trackback:ping><description><![CDATA[假设：<br />有个字段mytime，类型为日期/时间，格式为段时间<br />已经输入时间11:30<br />通过ADO访问:<br />(rs,r)=conn.Execute("select mytime from table1")<br /><br />1、print rs.Fields[1].Value<br />2、print repr(rs.Fields[1].Value)<br />3、print rs.Fields[1].Value.Format("%H:%M:%S %p")<br /><br />输出结果很稀奇（repr）：<br /><br />1、12/30/0/ 11:30:00<br />2、&amp;lt;PyTime:1899-12-30 星期六 上午 11:30:00&amp;gt;<br />3、11:30:00 AM<br /><img src ="http://www.blogjava.net/pts/aggbug/185989.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/pts/" target="_blank">pts</a> 2008-03-13 12:16 <a href="http://www.blogjava.net/pts/archive/2008/03/13/185989.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>python with ADO 的几点笔记</title><link>http://www.blogjava.net/pts/archive/2008/02/28/182794.html</link><dc:creator>pts</dc:creator><author>pts</author><pubDate>Thu, 28 Feb 2008 13:45:00 GMT</pubDate><guid>http://www.blogjava.net/pts/archive/2008/02/28/182794.html</guid><wfw:comment>http://www.blogjava.net/pts/comments/182794.html</wfw:comment><comments>http://www.blogjava.net/pts/archive/2008/02/28/182794.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/pts/comments/commentRss/182794.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/pts/services/trackbacks/182794.html</trackback:ping><description><![CDATA[1、几个重要的ADO对象：<br />
&nbsp;&nbsp;&nbsp; 首先<br />
&nbsp;&nbsp;&nbsp; from win32com.client import Dispatch<br />
&nbsp;&nbsp;&nbsp; 1.1、connection：<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; conn=Dispatch(r&#8216;ADODB.Connection')<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp; &nbsp;&nbsp;&nbsp; <strong>conn.ConnectionString</strong>可用值<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp; conn.Open()
<table style="text-align: left;" border="1" cellpadding="2" cellspacing="0" width="800">
    <tbody>
        <tr>
            <td style="text-align: left;"><strong>Database Engine</strong></td>
            <td width="600"><strong>ConnectionString</strong></td>
        </tr>
        <tr>
            <td>DBASE (using ODBC)</td>
            <td style="text-align: left;">Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=C:\path\to\database</td>
        </tr>
        <tr>
            <td>Excel (using ODBC)</td>
            <td>Driver={Microsoft Excel Driver (*.xls)};DriverID=790;Dbq=C:\path\to\spreadsheet;DefaultDir=C:\path\to\defaultdir</td>
        </tr>
        <tr>
            <td>Excel (using OLE DB)</td>
            <td>Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Path\To\sheet.xls;</td>
        </tr>
        <tr>
            <td>Access (using ODBC)</td>
            <td>Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\path\to\database.mdb;Uid=username;Pwd=password <br />
            <br />
            You can also pass additional options -- for example Exclusive=1; sets it to be opened in exclusive mode.</td>
        </tr>
        <tr>
            <td>Access (using OLE DB)</td>
            <td><strong>Using standard security</strong><br />
            PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\path\to\database.mdb;User Id=username;Password=somepassword;<br />
            (经测试，如果Access加密了，使用下面的connstring可以成功连接：<br />
            PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\path\to\database.mdb;Jet OLEDB:Databse Password=pwd;<br />
            )<br />
            <strong>Using Workgroup security</strong><br />
            str="Provider=Microsoft.Jet.OLEDB.4.0;DataSource=database.mdb;JET OLEDB:System Database=mysystem.mdw;"<br />
            oConn.Open(str, "my_user_name", "my_password")     </td>
        </tr>
        <tr>
            <td>Firebird</td>
            <td><strong>Remote Database</strong><br />
            Provider='LCPI.IBProvider';Data Source='remotehost:C:\path\to\database.fdb';User ID='username';Password='pwd';Auto Commit=true;<br />
            <br />
            The above is reported to work for a Firebird database by Edward Diamond (ediamond at water dot ca dot gov).  I would presume that it could work on a local Firebird server, simply by removing "remotehost"  from the string above. Edward reports that even simple queries don't work without the "Auto Commit"  part in the connection string.     </td>
        </tr>
        <tr>
            <td>MySQL (using ODBC)</td>
            <td><strong>Local Database</strong><br />
            Driver={MySQL ODBC 3.51 Driver};Server=localhost;User=username;Password=mypassword;Database=mydatabase;<br />
            <br />
            <strong>Remote Database</strong><br />
            Driver={MySQL ODBC 3.51 Driver};Server=192.168.1.100;Port=3306;User=username;Password=mypassword;Database=mydatabase;<br />
            <br />
            There are more parameters that can be set (for example, Option, which controls several connection properties such as logging, packet size limits etc.) See section 3.3 (Connection Parameters) of the <a href="http://www.mysql.com/products/myodbc/manual.html">MyODBC manual</a> for more information.  </td>
        </tr>
        <tr>
            <td>MySQL (using OLE DB)</td>
            <td>Provider=MySQLProv;Server=192.168.1.100;Port=3306;User=username;Password=mypassword;Database=mydatabase;<br />
            <br />
            If you have the datasource already set up:<br />
            Provider=MySQLProv;Data Source=name_of_datasource;<br />
            <br />
            You will need to <a href="http://www.mysql.com/get/Downloads/Win32/MyOLEDB3.exe/from/pick">download and install MyOleDB</a> first. Last time I checked MyOLEDB was no longer maintained.    </td>
        </tr>
        <tr>
            <td>Oracle (using ODBC)</td>
            <td>      Driver={Microsoft ODBC for Oracle};Server=MyOracleServer;Uid=username;Pwd=password<br />
            <br />
            See <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/orcdrvsdk_13.asp">the MSDN library</a> for additional options.    </td>
        </tr>
        <tr>
        </tr>
        <tr>
            <td>Oracle (using OLE DB)</td>
            <td>      <strong>Using OLE DB provider from Microsoft</strong><br />
            Provider=MSDAORA;Data Source=MyOracleDB;User Id=username;Password=password<br />
            See <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdreforacleprovspec.asp?frame=true">the MSDN library</a> for additional options.<br />
            <br />
            <strong>Using OLE DB provider from Oracle</strong><br />
            Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User Id=username;Password=password<br />
            </td>
        </tr>
        <tr>
            <td>SQL Server (using ODBC)</td>
            <td>      <strong>Standard Security</strong><br />
            Driver={SQL Server};Server=192.168.1.100;Uid=username;Pwd=password;Database=dbname;<br />
            <br />
            <strong>Trusted Connection</strong><br />
            Simply add Trusted_Connection=yes to the above string.<br />
            <br />
            See <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnodbc/html/odbcsql.asp">MSDN Library</a> for more options.    </td>
        </tr>
        <tr>
            <td style="text-align: left;">SQL Server (using OLE DB)</td>
            <td>      Provider=SQLOLEDB.1;Data Source=192.168.1.100;Uid=username;Pwd=password;Database=dbname;<br />
            <br />
            See <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdrefsqlprovspec.asp?frame=true">MSDN Library</a> for more options.</td>
        </tr>
    </tbody>
</table>
&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  1.2、command对象<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp; cmd=Dispatch(r'ADODB.Command')<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  cmd对象的几个属性设置及可用属性值：<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  <strong>CommandTyte:<br />
</strong>
<table border="1" cellpadding="4" cellspacing="4" cols="4" frame="box" rules="all" width="100%">
    <tbody>
        <tr valign="top">
            <th width="29%">常量</th> <th width="14%">值</th> <th width="57%">说明</th>
        </tr>
        <tr valign="top">
            <td class="T" width="29%"><strong>adCmdUnspecified</strong>  </td>
            <td class="T" width="14%">-1</td>
            <td class="T" width="57%">不指定命令类型的参数。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="29%"><strong>adCmdText</strong>  </td>
            <td class="T" width="14%">1</td>
            <td class="T" width="57%">按命令或存储过程调用的文本定义计算 CommandText。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="29%"><strong>adCmdTable</strong></td>
            <td class="T" width="14%">2</td>
            <td class="T" width="57%">按表名计算 <strong>CommandText</strong>，该表的列全部是由内部生成的 SQL  查询返回的。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="29%"><strong>adCmdStoredProc</strong></td>
            <td class="T" width="14%">4</td>
            <td class="T" width="57%">按存储过程名计算 <strong>CommandText</strong>。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="29%"><strong>adCmdUnknown</strong></td>
            <td class="T" width="14%">8</td>
            <td class="T" width="57%">默认值。指示 <strong>CommandText</strong> 属性中命令的类型未知。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="29%"><strong>adCmdFile</strong>  </td>
            <td class="T" width="14%">256</td>
            <td class="T" width="57%">按持久存储的 Recordset 的文件名计算  <strong>CommandText</strong>。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="29%"><strong>adCmdTableDirect</strong>  </td>
            <td class="T" width="14%">512</td>
            <td class="T" width="57%">按表名计算 <strong>CommandText</strong>，该表的列被全部返回。</td>
        </tr>
    </tbody>
</table>
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strong>CommandText:</strong>定义命令（例如 SQL 语句）的可执行文本<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp; <strong>Prepared:</strong>用 <strong>Prepared</strong> 属性将提供者保存为查询的已准备好（或已编译）版本，该查询是第一次执行 Command对象前在CommandText属性中指定的。这可能会降低命令第一次执行的速度，但一旦提供者编译一个命令后，便可将命令的编译版本用于所有后续的执行中，这样便可提高性能。 如果该属性为 False，提供者将直接执行 <strong>Command</strong> 对象而不创建编译版本。如果提供者不支持命令准备，则一旦将此属性设置为  <strong>True</strong>，提供者便可能返回错误。如果它不返回错误，则仅忽略准备命令的请求，并将 <strong>Prepared</strong> 属性设置为  <strong>False</strong>。&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  <strong>CommandTimeout:</strong> 属性设置提供者等待命令执行的秒数<br />
<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  1.3、Parameter对象<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  para1=cmd.CreateParameter(<em>Name, Type, Direction, Size, Value</em>）<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  Name&nbsp;&nbsp; 可选。String 值，包含 Parameter 对象的名称。<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Type&nbsp;&nbsp; 可选。DataTypeEnum 值，指定 Parameter 对象的数据类型。<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; Direction&nbsp;&nbsp; 可选。ParameterDirectionEnum 值，指定 Parameter 对象的类型。<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; Size&nbsp;&nbsp; 可选。Long 值，指定参数值的最大长度（以字符或字节为单位）。<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; Value&nbsp;&nbsp; 可选。Variant，指定 Parameter 对象的值。<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; <strong>DataTypeEnum 可用值：<br />
</strong>
<table border="1" cellpadding="4" cellspacing="4" cols="4" frame="box" rules="all" width="100%">
    <tbody>
        <tr valign="top">
            <th width="32%">常量</th> <th width="13%">值</th> <th width="55%">说明</th>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>AdArray<br />
            </strong>（不适用于 ADOX。）</td>
            <td class="T" width="13%">0x2000  </td>
            <td class="T" width="55%">一个标志值，通常与另一个数据类型常量组合，指示该数据类型的数组。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adBigInt</strong>  </td>
            <td class="T" width="13%">20</td>
            <td class="T" width="55%">指示一个八字节的有符号整数 (DBTYPE_I8)。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adBinary</strong>  </td>
            <td class="T" width="13%">128</td>
            <td class="T" width="55%">指示一个二进制值 (DBTYPE_BYTES)。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adBoolean</strong>  </td>
            <td class="T" width="13%">11</td>
            <td class="T" width="55%">指示一个布尔值 (DBTYPE_BOOL)。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adBSTR</strong>  </td>
            <td class="T" width="13%">8</td>
            <td class="T" width="55%">指示以 Null 终止的字符串 (Unicode) (DBTYPE_BSTR)。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adChapter</strong>  </td>
            <td class="T" width="13%">136</td>
            <td class="T" width="55%">指示一个四字节的子集值，标识子<a href="mddefrowset.htm">行集合</a>中的行  (DBTYPE_HCHAPTER)。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adChar</strong>  </td>
            <td class="T" width="13%">129</td>
            <td class="T" width="55%">指示一个字符串值 (DBTYPE_STR)。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adCurrency</strong>  </td>
            <td class="T" width="13%">6</td>
            <td class="T" width="55%">指示一个货币值 (DBTYPE_CY)。货币是一个定点数字，小数点右侧有四位数字。该值存储为八字节、范围为  10,000 的有符号整数。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adDate</strong>  </td>
            <td class="T" width="13%">7</td>
            <td class="T" width="55%">指示日期值 (DBTYPE_DATE)。日期保存为双精度数，数字的整数部分是从 1899 年 12 月 30  日算起的天数，小数部分是一天当中的片段时间。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adDBDate</strong>  </td>
            <td class="T" width="13%">133</td>
            <td class="T" width="55%">指示日期值 (yyyymmdd) (DBTYPE_DBDATE)。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adDBTime</strong>  </td>
            <td class="T" width="13%">134</td>
            <td class="T" width="55%">指示时间值 (hhmmss) (DBTYPE_DBTIME)。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adDBTimeStamp</strong>  </td>
            <td class="T" width="13%">135</td>
            <td class="T" width="55%">指示日期/时间戳（yyyymmddhhmmss  加十亿分之一的小数）(DBTYPE_DBTIMESTAMP)。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adDecimal</strong>  </td>
            <td class="T" width="13%">14</td>
            <td class="T" width="55%">指示具有固定精度和范围的确切数字值 (DBTYPE_DECIMAL)。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adDouble</strong>  </td>
            <td class="T" width="13%">5</td>
            <td class="T" width="55%">指示一个双精度浮点值 (DBTYPE_R8)。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adEmpty</strong>  </td>
            <td class="T" width="13%">0</td>
            <td class="T" width="55%">指定没有值 (DBTYPE_EMPTY)。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adError</strong>  </td>
            <td class="T" width="13%">10</td>
            <td class="T" width="55%">指示一个 32 位的错误代码 (DBTYPE_ERROR)。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adFileTime</strong>  </td>
            <td class="T" width="13%">64</td>
            <td class="T" width="55%">指示一个 64 位的值，表示从 1601 年 1 月 1 日开始的 100 个十亿分之一秒间隔的数量  (DBTYPE_FILETIME)。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adGUID</strong>  </td>
            <td class="T" width="13%">72</td>
            <td class="T" width="55%">指示全局唯一标识符 (GUID) (DBTYPE_GUID)。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adIDispatch</strong>  </td>
            <td class="T" width="13%">9</td>
            <td class="T" width="55%">指示指向 COM 对象上 <strong>IDispatch</strong> 接口的指针 (DBTYPE_IDISPATCH)。
            <p class="T"><strong>注意&nbsp;&nbsp;&nbsp;</strong>ADO 目前不支持这种数据类型。使用它可能导致不可预料的结果。</p>
            </td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adInteger</strong>  </td>
            <td class="T" width="13%">3</td>
            <td class="T" width="55%">指示一个四字节的有符号整数 (DBTYPE_I4)。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adIUnknown</strong>  </td>
            <td class="T" width="13%">13</td>
            <td class="T" width="55%">指示指向 COM 对象上 <strong>IUnknown</strong> 接口的指针 (DBTYPE_IUNKNOWN)。
            <p class="T"><strong>注意&nbsp;&nbsp;&nbsp;</strong>ADO 目前不支持这种数据类型。使用它可能导致不可预料的结果。</p>
            </td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adLongVarBinary</strong>  </td>
            <td class="T" width="13%">205</td>
            <td class="T" width="55%">指示一个长二进制值（仅限于 <strong>Parameter</strong> 对象）。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adLongVarChar</strong>  </td>
            <td class="T" width="13%">201</td>
            <td class="T" width="55%">指示一个长字符串值（仅限于 <strong>Parameter</strong> 对象）。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adLongVarWChar</strong>  </td>
            <td class="T" width="13%">203</td>
            <td class="T" width="55%">指示一个以 Null 终止的长 Unicode 字符串值（仅限于 <strong>Parameter</strong>  对象）。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adNumeric</strong>  </td>
            <td class="T" width="13%">131</td>
            <td class="T" width="55%">指示具有固定精度和范围的确切数字值 (DBTYPE_NUMERIC)。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adPropVariant</strong>  </td>
            <td class="T" width="13%">138</td>
            <td class="T" width="55%">指示一个 Automation PROPVARIANT  (DBTYPE_PROP_VARIANT)。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adSingle</strong>  </td>
            <td class="T" width="13%">4</td>
            <td class="T" width="55%">指示一个单精度浮点值 (DBTYPE_R4)。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adSmallInt</strong>  </td>
            <td class="T" width="13%">2</td>
            <td class="T" width="55%">指示一个双字节的有符号整数 (DBTYPE_I2)。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adTinyInt</strong>  </td>
            <td class="T" width="13%">16</td>
            <td class="T" width="55%">指示一个单字节的有符号整数 (DBTYPE_I1)。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adUnsignedBigInt</strong>  </td>
            <td class="T" width="13%">21</td>
            <td class="T" width="55%">指示一个八字节的无符号整数 (DBTYPE_UI8)。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adUnsignedInt</strong>  </td>
            <td class="T" width="13%">19</td>
            <td class="T" width="55%">指示一个四字节的无符号整数 (DBTYPE_UI4)。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adUnsignedSmallInt</strong>  </td>
            <td class="T" width="13%">18</td>
            <td class="T" width="55%">指示一个双字节的无符号整数 (DBTYPE_UI2)。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adUnsignedTinyInt</strong>  </td>
            <td class="T" width="13%">17</td>
            <td class="T" width="55%">指示一个单字节的无符号整数 (DBTYPE_UI1)。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adUserDefined</strong>  </td>
            <td class="T" width="13%">132</td>
            <td class="T" width="55%">指示一个用户定义的变量 (DBTYPE_UDT)。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adVarBinary</strong>  </td>
            <td class="T" width="13%">204</td>
            <td class="T" width="55%">指示一个二进制值（仅限于 <strong>Parameter</strong> 对象）。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adVarChar</strong>  </td>
            <td class="T" width="13%">200</td>
            <td class="T" width="55%">指示一个字符串值（仅限于 <strong>Parameter</strong> 对象）。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adVariant</strong>  </td>
            <td class="T" width="13%">12</td>
            <td class="T" width="55%">指示一个 Automation <strong>Variant</strong> (DBTYPE_VARIANT)。
            <p class="T"><strong>注意&nbsp;&nbsp;&nbsp;</strong>ADO 目前不支持这种数据类型。使用它可能导致不可预料的结果。</p>
            </td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adVarNumeric</strong>  </td>
            <td class="T" width="13%">139</td>
            <td class="T" width="55%">指示一个数字值（仅限于 <strong>Parameter</strong> 对象）。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adVarWChar</strong>  </td>
            <td class="T" width="13%">202</td>
            <td class="T" width="55%">指示一个以 Null 终止的 Unicode 字符串（仅限于 <strong>Parameter</strong>  对象）。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adWChar</strong>  </td>
            <td class="T" width="13%">130</td>
            <td class="T" width="55%">指示一个以 Null 终止的 Unicode 字符串 (DBTYPE_WSTR)。</td>
        </tr>
    </tbody>
</table>
<br />
<strong>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ParameterDirectionEnum可用值：<br />
</strong>
<table border="1" cellpadding="4" cellspacing="4" cols="4" frame="box" rules="all" width="100%">
    <tbody>
        <tr valign="top">
            <th width="32%">常量</th> <th width="10%">值</th> <th width="58%">说明</th>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adParamInput</strong>  </td>
            <td class="T" width="10%">1</td>
            <td class="T" width="58%">默认值。指示该参数是输入参数。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adParamInputOutput</strong>  </td>
            <td class="T" width="10%">3</td>
            <td class="T" width="58%">指示该参数既是输入参数，又是输出参数。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adParamOutput</strong>  </td>
            <td class="T" width="10%">2</td>
            <td class="T" width="58%">指示该参数是输出参数。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adParamReturnValue</strong>  </td>
            <td class="T" width="10%">4</td>
            <td class="T" width="58%">指示该参数是返回值。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adParamUnknown</strong>  </td>
            <td class="T" width="10%">0</td>
            <td class="T" width="58%">指示该参数的方向未知。</td>
        </tr>
    </tbody>
</table>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  <br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  设定好后加入到cmd的parameters中：<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp; cmd.Parameters.Append(para1)<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp; 设定para1的值：<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  para1.Value=***<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp; 执行cmd：<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp; (rst,result)=cmd.Execute()<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  1.4、recordset对象：<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  rst=Dispatch(r'ADODB.Recordset')<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  rst对象在Open前可设置游标类型：<br />
<ul>
    <ul>
        <ul>
            <ul>
                <ul>
                    <li><strong>动态游标</strong><strong> adOpenDynamic</strong>— 用于查看其他用户所作的添加、更改和删除；用于  <strong>Recordset</strong>（不依赖于书签）中的所有移动类型；如果提供者支持，还可用于书签。</li>
                </ul>
            </ul>
        </ul>
    </ul>
    <ul>
        <ul>
            <ul>
                <ul>
                    <li><strong>键集游标 </strong><strong>adOpenKeyset</strong><strong> </strong>—  其行为类似动态游标，不同的只是它禁止查看其他用户添加的记录，并且禁止访问其他用户删除的记录。其他用户所作的数据更改依然可见。它始终支持书签，因此允许  <strong>Recordset </strong>中的所有移动类型。&nbsp;&nbsp;</li>
                    <li><strong>静态游标</strong><strong> adOpenStatic</strong>— 提供记录集的静态副本，可用来查找数据或生成报告；它始终支持书签，因此允许  <strong>Recordset</strong> 中的所有移动类型。其他用户所作的添加、更改或删除将不可见。当打开客户端 <strong>Recordset</strong> 对象时，这是唯一允许的游标类型。</li>
                    <li><strong>仅向前游标</strong><strong> </strong><strong>adOpenForwardOnly</strong>— 只允许在 <strong>Recordset</strong>  中向前滚动。其他用户所作的添加、更改或删除将不可见。当只需要对 <strong>Recordset</strong> 进行一次传递时，可以提高性能。 <br />
                    </li>
                </ul>
            </ul>
        </ul>
    </ul>
</ul>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  具体游标值为：<br />
<table border="1" cellpadding="4" cellspacing="4" cols="4" frame="box" rules="all" width="100%">
    <tbody>
        <tr valign="top">
            <td class="T" width="32%"><strong>adOpenDynamic</strong>
            </td>
            <td class="T" width="10%">2</td>
            <td class="T" width="58%">使用动态<a href="mddefcursor.htm">游标</a>。其他用户所作的添加、更改或删除均可见，而且允许 <strong>Recordset</strong>
            中的所有移动类型（如果提供者不支持书签，则书签除外）。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adOpenForwardOnly</strong>
            </td>
            <td class="T" width="10%">0</td>
            <td class="T" width="58%"><strong><em>默认值。</em></strong>使用仅向前游标。除了在记录中只能向前滚动外，与静态游标相同。当只需要在 <strong>Recordset</strong>
            中进行一个传递时，用它可提高性能。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adOpenKeyset</strong>
            </td>
            <td class="T" width="10%">1</td>
            <td class="T" width="58%">使用键集游标。尽管从您的 <strong>Recordset</strong>
            不能访问其他用户删除的记录，但除无法查看其他用户添加的记录外，它和动态游标相似。其他用户所作的数据更改依然可见。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adOpenStatic</strong>
            </td>
            <td class="T" width="10%">3</td>
            <td class="T" width="58%">使用静态游标。一组记录的静态副本，可用于查找数据或生成报告。其他用户所作的添加、更改或删除不可见。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adOpenUnspecified</strong>
            </td>
            <td class="T" width="10%">-1</td>
            <td class="T" width="58%">不指定游标类型。</td>
        </tr>
    </tbody>
</table>
<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  <em>rst</em><strong>.Open（</strong><code></code><em>Source</em><strong>,
</strong><em>ActiveConnection</em><strong>, </strong><em>CursorType</em><strong>,
</strong><em>LockType</em><strong>, </strong><em>Options</em>）<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  参数值全部可选。<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  CursorType上面已经说明<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  LockType的可选值：<br />
<table border="1" cellpadding="4" cellspacing="4" cols="4" frame="box" rules="all" width="100%">
    <tbody>
        <tr valign="top">
            <th width="32%">常量</th>
            <th width="10%">值</th>
            <th width="58%">说明</th>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adLockBatchOptimistic</strong>
            </td>
            <td class="T" width="10%">4</td>
            <td class="T" width="58%">指示开放式批更新。需要批更新模式。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adLockOptimistic</strong>
            </td>
            <td class="T" width="10%">3</td>
            <td class="T" width="58%">指示逐个记录开放式锁定。提供者使用开放式锁定，仅在调用 <a href="mdmthupdate.htm">Update</a> 方法时锁定记录。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adLockPessimistic</strong>
            </td>
            <td class="T" width="10%">2</td>
            <td class="T" width="58%">指示逐个记录保守式锁定。提供者要确保记录编辑成功，通常在编辑之后立即在数据源锁定记录。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adLockReadOnly</strong>
            </td>
            <td class="T" width="10%">1</td>
            <td class="T" width="58%"><strong><em>默认值</em></strong>。指示只读记录。无法改变数据。</td>
        </tr>
        <tr valign="top">
            <td class="T" width="32%"><strong>adLockUnspecified</strong>
            </td>
            <td class="T" width="10%">-1</td>
            <td class="T" width="58%">未指定锁定类型。创建副本时，副本与源对象使用相同的锁定类型。</td>
        </tr>
    </tbody>
</table>
<br />
<img src ="http://www.blogjava.net/pts/aggbug/182794.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/pts/" target="_blank">pts</a> 2008-02-28 21:45 <a href="http://www.blogjava.net/pts/archive/2008/02/28/182794.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>python 访问加密的access文件</title><link>http://www.blogjava.net/pts/archive/2008/02/26/182318.html</link><dc:creator>pts</dc:creator><author>pts</author><pubDate>Tue, 26 Feb 2008 14:19:00 GMT</pubDate><guid>http://www.blogjava.net/pts/archive/2008/02/26/182318.html</guid><wfw:comment>http://www.blogjava.net/pts/comments/182318.html</wfw:comment><comments>http://www.blogjava.net/pts/archive/2008/02/26/182318.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/pts/comments/commentRss/182318.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/pts/services/trackbacks/182318.html</trackback:ping><description><![CDATA[import win32com.client<br />conn=win32com.client.Dispatch(r'ADODB.Connection')<br />dsn='PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=d:/temp/test/test1.mdb;<font color="#ff0000"><u>Jet OLEDB:Database Password=555555;</u></font>'<br />conn.Open(dsn)<br />rst=win32com.client.Dispatch(r'ADODB.Recordset')<br />rst.ActiveConnection=conn<br />rst.Open('yandan')<br /><br />关键是这里：<br />Jet OLEDB:Database Password=123456;<br />要提供通过独占方式打开mdb文件后-&gt;安全-&gt;设置密码 后，再打开时要输入的密码<br /><img src ="http://www.blogjava.net/pts/aggbug/182318.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/pts/" target="_blank">pts</a> 2008-02-26 22:19 <a href="http://www.blogjava.net/pts/archive/2008/02/26/182318.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>VBA中初始化ADO连接的几种方法</title><link>http://www.blogjava.net/pts/archive/2007/02/01/97357.html</link><dc:creator>pts</dc:creator><author>pts</author><pubDate>Thu, 01 Feb 2007 13:16:00 GMT</pubDate><guid>http://www.blogjava.net/pts/archive/2007/02/01/97357.html</guid><wfw:comment>http://www.blogjava.net/pts/comments/97357.html</wfw:comment><comments>http://www.blogjava.net/pts/archive/2007/02/01/97357.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/pts/comments/commentRss/97357.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/pts/services/trackbacks/97357.html</trackback:ping><description><![CDATA[VBA中初始化ADO连接的几种方法<br />
<br />
VBA中初始化ADO连接的几种方法有以下几种：<br />
<br />
1．通过CreateObject方法来创建连接，具体代码如下：<br />
<br />
Dim
conn1<br />
<br />
Set conn1 = CreateObject("ADODB.Connection.2.0")
<br />
<br />
2．通过使用Dim ... as ...方法来创建连接<br />
<br />
Dim conn2 As
ADODB.Connection<br />
<br />
Set conn2 = New ADODB.Connection<br />
<br />
3．通过使用Dim
... as ... New的方法来创建连接<br />
<br />
Dim conn3 As new
ADODB.Connection<br />
<br />
CreateObject方法比DIM方法速度要慢，其好处是你不需要在工程中引用ADO对象。<br />
<br />
<p class="poweredbyperformancing">powered by <a href="http://performancing.com/firefox">performancing firefox</a></p>
<img src ="http://www.blogjava.net/pts/aggbug/97357.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/pts/" target="_blank">pts</a> 2007-02-01 21:16 <a href="http://www.blogjava.net/pts/archive/2007/02/01/97357.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>经典SQL语句集锦(收藏版)</title><link>http://www.blogjava.net/pts/archive/2006/11/11/80646.html</link><dc:creator>pts</dc:creator><author>pts</author><pubDate>Sat, 11 Nov 2006 15:42:00 GMT</pubDate><guid>http://www.blogjava.net/pts/archive/2006/11/11/80646.html</guid><wfw:comment>http://www.blogjava.net/pts/comments/80646.html</wfw:comment><comments>http://www.blogjava.net/pts/archive/2006/11/11/80646.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/pts/comments/commentRss/80646.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/pts/services/trackbacks/80646.html</trackback:ping><description><![CDATA[<p><a href="http://www.blogjava.net/lbx19822004/archive/2006/10/18/75893.html">经典SQL语句集锦(收藏版)</a><br />
</p>
<br />
<img src ="http://www.blogjava.net/pts/aggbug/80646.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/pts/" target="_blank">pts</a> 2006-11-11 23:42 <a href="http://www.blogjava.net/pts/archive/2006/11/11/80646.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>