阵列/记录? [英] array/recordset?

查看:64
本文介绍了阵列/记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有人,


好​​的 - 这就是我的目标,然后我想 - 呐喊,那不能

是对的!< br $>
查询数据库

结果记录集

结果使用GetRows数组

更新一列中的值在数组中

< BOING>

意识到你无法轻松排序数组......嗯,也许我放了数组

将内容写入记录集我可以对它们进行排序


< DUH>


以上对我来说似乎很愚蠢,即记录集,数组,到记录集 -

最后我*将*实际上需要它们在数组中....


所以,是否可以更新一个记录集一旦从数据库中拉出来了吗?

这可能是一个愚蠢的问题,但它不是我以前做过的事情

所以不确定?如果是这样的话,一个小例子会很方便...


我基本上计算一个需要存储在

行的字段,同时迭代整个地段。


任何信息赞赏。


问候


Rob

Lo all,

Ok - this is what I was aiming to do, and then I thought - naahhh, that cant
be right!

query database
results to recordset
results to array using GetRows
update values in one column in array
<BOING>
realised you cant sort an array easily..."hmmm, perhaps if I put the array
contents into a recordset I could sort them"

<DUH>

The above seems pretty stupid to me, ie, recordset, to array, to recordset -
where finally I *will* actually need them in an array anyway....

So, is it possible to update a recordset once its pulled from the database?
It''s probably a stupid question, but its not something I''ve ever done before
so wasn''t sure? If so, a small example would be handy...

I''m basically calculating a field which needs to be stored back against the
row whilst iterating through the whole lot.

Any info appreciated.

Regards

Rob

推荐答案

Rob Meade写道:
Rob Meade wrote:
Lo all,

好的 - 这就是我的目标要做,然后我想 - 呐喊,
那是对的!

查询数据库结果到记录集
结果使用GetRows
更新数组中一列中的值
< BOING>
意识到你无法轻松排序数组...嗯,也许如果我将
数组内容放入记录集中我可以对它们进行排序 ;

< DUH>

以上对我来说似乎很愚蠢,即记录集,数组,记录集 - 最后我*将*实际上无论如何需要他们在阵列中....

那么,一旦从数据库中取出记录集,是否可以更新记录集?这可能是一个愚蠢的问题,但这不是我以前做过的事情,所以不确定吗?如果是这样的话,一个小例子将会很方便......

我基本上在计算一个需要在行中存储的字段,同时在整个行中进行迭代很多。

任何信息赞赏。

问候

Rob
Lo all,

Ok - this is what I was aiming to do, and then I thought - naahhh,
that cant be right!

query database
results to recordset
results to array using GetRows
update values in one column in array
<BOING>
realised you cant sort an array easily..."hmmm, perhaps if I put the
array contents into a recordset I could sort them"

<DUH>

The above seems pretty stupid to me, ie, recordset, to array, to
recordset - where finally I *will* actually need them in an array
anyway....

So, is it possible to update a recordset once its pulled from the
database? It''s probably a stupid question, but its not something I''ve
ever done before so wasn''t sure? If so, a small example would be
handy...

I''m basically calculating a field which needs to be stored back
against the row whilst iterating through the whole lot.

Any info appreciated.

Regards

Rob




为什么可以在用于打开记录集的查询中进行计算,

然后使用Order By子句中的计算列?这将是

最有效的方法。


或者:

使用adLockBatchOptimistic的LockType打开记录集(4),并且

将ActiveConnection属性设置为Nothing,您可以从数据库断开

记录集(甚至可以关闭并销毁连接

如果你愿意的话 - 这通常是一个好主意,除非你在页面后面使用连接计划

)。这将允许您更新记录集

而不会影响数据库中的数据。一旦你有了b $ b更新了数据,就可以使用记录集的Sort方法对

结果进行排序,然后再使用getrows将其转换为数组。 />

设置rs = server.createobject(" adodb.recordset")

rs.cursorlocation = adUseClient

rs.Open SQL, cn ,, adLockBatchOptimistic,adCmdText

set rs.activeconnection = nothing

cn.close:set cn = nothing


或者,如果你没有定义常量:

设置rs = server.createobject(" adodb.recordset")

rs.cursorlocation = 3

rs.Open SQL,cn ,, 4,1

set rs.activeconnection = nothing

cn.close:set cn = nothing


您现在可以使用Update方法进行更新。


如果您想将这些更改保存回数据库,您可以设置

activeconnection属性返回打开的连接,并调用UpdateBatch

将更改发送到数据基础。

HTH,

Bob Barrows

-

Microsoft MVP - ASP / ASP.NET

请回复新闻组。这个电子邮件帐户是我的垃圾邮件陷阱所以我

不经常检查它。如果你必须离线回复,那么删除

NO SPAM



Why can''t the calculation be done in the query used to open the recordset,
then use the calculated column in the Order By clause? That would be the
most efficient means of doing this.

Alternatively:
By opening the recordset using a LockType of adLockBatchOptimistic (4), and
setting the ActiveConnection property to Nothing, you can disconnect a
recordset from the database (you can even close and destroy the Connection
at this point if you wish - it''s usually a good idea unless you plan on
using the connection later on in the page). This will allow you to update
the recordset without affecting the data in the database. And once you have
updated the data, you can use the recordset''s Sort method to sort the
results before using getrows to convert it to an array.

Set rs=server.createobject("adodb.recordset")
rs.cursorlocation = adUseClient
rs.Open SQL, cn, ,adLockBatchOptimistic,adCmdText
set rs.activeconnection=nothing
cn.close:set cn=nothing

or, if you don''t have the constants defined:
Set rs=server.createobject("adodb.recordset")
rs.cursorlocation = 3
rs.Open SQL, cn, ,4,1
set rs.activeconnection=nothing
cn.close:set cn=nothing

You can now do your updates, using the Update method.

If you wanted to save these changes back to the database, you would set the
activeconnection property back to an open connection, and call UpdateBatch
to send the changes to the database.
HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don''t check it very often. If you must reply off-line, then remove the
"NO SPAM"


" Bob Barrows"写道......


嘿嘿Bob:o)
"Bob Barrows" wrote ...

Hey ho Bob :o)
为什么不能在用于打开的查询中进行计算记录集,然后使用Order By子句中的计算列?这将是最有效的方法。


确实会 - 但是 - 我不知道如何在SQL语句中我可以计算

总数来自搜索条件的每个单词的总数在每个

字段中,以及所有单词/任何单词/完全短语的3个案例 -

因此在SQL和ASP中完成...

或者:
通过使用adLockBatchOptimistic(4)的LockType打开记录集,
并将ActiveConnection属性设置为Nothing,您可以断开
记录集与数据库的连接(您可以如果你愿意的话,甚至关闭并破坏连接
- 除非你计划在页面中稍后使用连接,否则通常是一个好主意。这将允许您更新记录集而不会影响数据库中的数据。


有问题的栏目是我喜欢称之为仙女的,它确实不存在
存在(但我觉得它有点):o)


ie,我选择4个真实字段,然后我添加一个,如下:

SELECT websiteid,websitename,websitedesc,websitemeta, 0 AS相关性

来自....


它的相关性字段将在ASP中更新(希望),一次

每一行都会根据相关性进行更新和排序,然后我会将它们全部放入数组中以显示到页面等等。

一旦你已更新数据,您可以使用记录集的Sort
方法对结果进行排序,然后再使用getrows将其转换为数组。
Why can''t the calculation be done in the query used to open the recordset,
then use the calculated column in the Order By clause? That would be the
most efficient means of doing this.
Indeed it would - but - I dont know how in a SQL statement I can count the
total number of times each word form the search criteria is found in each
field, and across the 3 cases of all words / any words / exact phrase -
hence doing out of SQL and in ASP...
Alternatively:
By opening the recordset using a LockType of adLockBatchOptimistic (4), and setting the ActiveConnection property to Nothing, you can disconnect a
recordset from the database (you can even close and destroy the Connection
at this point if you wish - it''s usually a good idea unless you plan on
using the connection later on in the page). This will allow you to update
the recordset without affecting the data in the database.
The column in question is what I like to call a fairy, it doesnt really
exist (but I guess it kinda does) :o)

ie, I select 4 real fields for example, and then I add one, like this :

SELECT websiteid, websitename, websitedesc, websitemeta, 0 AS Relevance
FROM....

its the Relevance field that will be updated(hopefully) in the ASP, once
each row is updated and sorted based on Relevance, I''ll then drop it all
into an array for display to the page etc..
And once you have updated the data, you can use the recordset''s Sort method to sort the results before using getrows to convert it to an array.




是的 - 多数民众赞成我想要的东西:)


我认为我目前的连接字符串(在整个网站上大量用于
不同的页面来做不同的事情等)是导致我当前的错误:


设置objCommand2 = Server.CreateObject(" ADODB.Command")

设置RS2 = Server.CreateObject(" ADODB.Recordset")

objCommand2.CommandText = SQL2

objCommand2.CommandType = adCmdText

设置objCommand2.ActiveConnection = objConnection2

RS2.Open objCommand2 ,, adOpenKeySet,adLockOptimistic


当前错误:


用于ODBC驱动程序的Microsoft OLE DB提供程序错误''80040e21''

多步OLE DB操作生成错误。检查每个OLE DB状态

值(如果有)。没有工作。

/parasolit/statics/mainbody-search-results.asp,第631行

这是我的命令在上面的底线引起的

更新问题?在不影响应用程序其余部分的情况下将这些更改为其他内容是否安全?b $ b? (也许值得拥有一个新的连接

字符串只为此等)...

还有更多的帮助,

问候

Rob



yep - thats what I want :)

I think my current connection string (used vastly across the entire site on
different pages to do different stuff etc) is causing me my current error :

Set objCommand2 = Server.CreateObject("ADODB.Command")
Set RS2 = Server.CreateObject("ADODB.Recordset")
objCommand2.CommandText = SQL2
objCommand2.CommandType = adCmdText
Set objCommand2.ActiveConnection = objConnection2
RS2.Open objCommand2,,adOpenKeySet, adLockOptimistic

Current error :

Microsoft OLE DB Provider for ODBC Drivers error ''80040e21''
Multiple-step OLE DB operation generated errors. Check each OLE DB status
value, if available. No work was done.
/parasolit/statics/mainbody-search-results.asp, line 631
Is this my commands on the bottom line of the above that are causing the
problems with the update? Is it safe to change these to something else
without affecting the rest of the app? (maybe worth having a new connection
string just for this etc)...
Any more help appreciated,
Regards
Rob


Rob Meade写道:
Rob Meade wrote:
" Bob Barrows"写道......

Hey ho Bob:o)
"Bob Barrows" wrote ...

Hey ho Bob :o)
为什么不能在用于打开的查询中进行计算
记录集,然后使用Order By子句中的计算列?
这将是最有效的方法。
确实会 - 但是 - 我不知道如何在SQL语句中我可以
计算在每个字段中找到每个单词形成搜索条件的总次数,以及所有单词/任何单词的3个案例
/完全短语 - 因此在SQL和ASP ...
Why can''t the calculation be done in the query used to open the
recordset, then use the calculated column in the Order By clause?
That would be the most efficient means of doing this.
Indeed it would - but - I dont know how in a SQL statement I can
count the total number of times each word form the search criteria is
found in each field, and across the 3 cases of all words / any words
/ exact phrase - hence doing out of SQL and in ASP...




如果是SQL Server,这可以在存储过程中使用

临时表或表来执行变量,但是...我认为你正在使用Access ...?



If it was SQL Server, this would be do-able in a stored procedure using a
temp table or table variable, but ... I think you''re using Access ...?

或者:
使用lockType of adLockBatchOptimistic打开记录集
(4),并将ActiveConnection属性设置为Nothing,您可以将记录集与数据库断开连接ase(如果你愿意的话,你甚至可以关闭和
销毁连接 - 除非你打算稍后在
页面中使用连接,否则它通常是个好主意) 。这将允许您更新记录集而不影响数据库中的数据。
Alternatively:
By opening the recordset using a LockType of adLockBatchOptimistic
(4), and setting the ActiveConnection property to Nothing, you can
disconnect a recordset from the database (you can even close and
destroy the Connection at this point if you wish - it''s usually a
good idea unless you plan on using the connection later on in the
page). This will allow you to update the recordset without affecting
the data in the database.



有问题的列是我喜欢称之为仙女的,它不是
确实存在(但我猜它有点):o)

即,我选择4个真实的字段,然后我添加一个,像这样


SELECT websiteid,websitename,websitedesc,websitemeta,0 AS
相关性来自....



The column in question is what I like to call a fairy, it doesnt
really exist (but I guess it kinda does) :o)

ie, I select 4 real fields for example, and then I add one, like this
:

SELECT websiteid, websitename, websitedesc, websitemeta, 0 AS
Relevance FROM....




计算字段不可更新。这样就不会出现原始记录集更新解决方案了。这留下了三个选项。


1.在服务器端代码中使用javascript。排序数组是单行的

javascript

2.使用ad hoc记录集

3.编写代码对数组进行排序


这是一个链接,我在7月回复Robb Meade的帖子(你好吗?

):
http://groups.google.com/groups?q=do...xx。 gbl& rnum = 1

这里是我发的另一篇文章的链接,其中我比较了

技巧2和3的表现:
http: //groups.google.com/groups?hl=e...o输出%2B%253F


HTH,

Bob Barrows

-

Microsoft MVP - ASP / ASP.NET

请回复新闻组。这个电子邮件帐户是我的垃圾邮件陷阱所以我

不经常检查它。如果您必须离线回复,请删除

无垃圾邮件



Calculated fields are not updatable. So that leaves the
original-recordset-update solution out. This leaves three options.

1. Use javascript in your server-side code. Sorting an array is a one-liner
in javascript
2. Use an ad hoc recordset
3. Write code to sort the array

Here''s a link to a post I made back in July in response to Robb Meade (was
that you?):
http://groups.google.com/groups?q=do...phx.gbl&rnum=1
Here''s a link to another post I made in which I compared the performance of
techniques 2 and 3:
http://groups.google.com/groups?hl=e...output%2B%253F

HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don''t check it very often. If you must reply off-line, then remove the
"NO SPAM"


这篇关于阵列/记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆