“(null)”的Createobject导致异常C0000005 [英] Createobject of '(null)' caused exception C0000005

查看:80
本文介绍了“(null)”的Createobject导致异常C0000005的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我间歇性地在我的asp页面上收到此错误。有一天很好,再过一天,它会崩溃很多。我在网上和微软上搜索了

这个,他们说这是一个分配给会话变量的记录集。


我没有为会话分配任何记录集我的代码中的变量。我将

值分配给会话变量。

它似乎崩溃的地方是Set AccessConn =

Server.CreateObject(" ADODB) .Connection")

代码:


connstr =" Provider = Microsoft.Jet.OLEDB.4.0; Data Source =" &

Server.mapPath(" EmployeeTransactions.mdb")

设置AccessConn = Server.CreateObject(" ADODB.Connection")

AccessConn.open connstr


''获取会话(" loc")以查看是否允许他们更新记录

lloc = session(" sploctype")

loccode = session(" splocationdesc")


if lloc =" School"然后

accessupdate = 0

else

accessupdate = 1

结束如果


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

sql =" select emprecid,employeeno,employeelastname,employeofirstname,

iif(isnull) (hrstatus),''& nbsp'',hrstatus)作为hrstatus,

iif(isnull(hrdate),'& nbsp'',hrdate)作为hrdate,

iif(isnull(budgetstatus),''& nbsp'',budgetstatus)as budgetstatus,

iif(isnull(budgetdate),'& nbsp'',budgetdate)as budgetdate ," &安培; _

" iif(isnull(payrollstatus),''& nbsp'',payrollstatus)作为payrollstatus,

iif(isnull(payrolldate),''& nbsp'',payrolldate)as payrolldate,

iif(isnull(benefitdate),''& nbsp'',benefitdate)作为福利日期,

iif(isnull(createdby),''& nbsp'',createdby )as created,

iif(isnull(processstatus),''& nbsp'',processstatus)作为processstatus,

employeetype,来自employeetransaction的位置"


''我们只显示学校位置的记录,否则,我们为部门显示



如果lloc =" School"然后

sql = sql& "其中location =''" &安培; loccode& "''和

((EmployeeTransaction.PayrollDate> =(date() - 30))或

(Isnull([EmployeeTransaction]。[PayrollDate])< ;> FALSE))通过emprecid命令

desc"

else

sql = sql& " where((EmployeeTransaction.PayrollDate> =(date() - 30))或

(Isnull([EmployeeTransaction]。[PayrollDate])<> FALSE))按照emprecid desc
"

结束如果

设置rs = AccessConn.execute(sql)


有什么想法吗? ?

谢谢,


Hi,

I''m getting this error on my asp page intermittently. One day it is fine,
another day, it crashes a lot. I have searched the web and microsoft on
this and they say it is a recordset assigned to a session variable.

I dont assign any record sets to session variables in my code. I assign
values to the session variables though.
The place it seems to crash is Set AccessConn =
Server.CreateObject("ADODB.Connection")

code:

connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.mapPath("EmployeeTransactions.mdb")
Set AccessConn = Server.CreateObject("ADODB.Connection")
AccessConn.open connstr

''get session("loc") to see if they are allowed to update records
lloc = session("sploctype")
loccode = session("splocationdesc")

''Determining the ability to access update records
if lloc = "School" then
accessupdate = 0
else
accessupdate = 1
end if

Set rs = Server.CreateObject("ADODB.Recordset")
sql = "select emprecid, employeeno, employeelastname, employeefirstname,
iif(isnull(hrstatus),''&nbsp'',hrstatus) as hrstatus,
iif(isnull(hrdate),''&nbsp'',hrdate) as hrdate,
iif(isnull(budgetstatus),''&nbsp'',budgetstatus) as budgetstatus,
iif(isnull(budgetdate),''&nbsp'',budgetdate) as budgetdate," & _
" iif(isnull(payrollstatus),''&nbsp'',payrollstatus) as payrollstatus,
iif(isnull(payrolldate),''&nbsp'',payrolldate) as payrolldate,
iif(isnull(benefitdate),''&nbsp'',benefitdate) as benefitdate,
iif(isnull(createdby),''&nbsp'',createdby) as createdby,
iif(isnull(processstatus),''&nbsp'',processstatus) as processstatus,
employeetype, location from employeetransaction "

''we only display the records for the school location otherwise, we display
all for departments
if lloc="School" then
sql = sql & " where location = ''" & loccode & "'' and
((EmployeeTransaction.PayrollDate >=(date()-30)) OR
(Isnull([EmployeeTransaction].[PayrollDate])<> FALSE)) order by emprecid
desc "
else
sql = sql & " where ((EmployeeTransaction.PayrollDate >= (date()-30)) OR
(Isnull([EmployeeTransaction].[PayrollDate])<>FALSE)) order by emprecid desc
"
end if
set rs = AccessConn.execute(sql)

Any ideas??
thanks,
Will

推荐答案

几个建议。


(a)不要使用Server.CreateObject,只需要CreateObject


(b)什么是设置rs = Server.CreateObject(" ADODB.Recordset" )为?你稍后用set rs = AccessConn.execute(sql)覆盖它...
我也改变了

" AccessConn"更加标准的Conn......


(c)在查询中不做演示文稿(用& nbsp;替换null)。

在表示层中执行它所属的位置!只要你从结果集中返回需要至少为& nbsp;的

值,请使用

我在下面写的函数sb( showblanks)。或者,只是response.write

rs(" column")& "&安培; NBSP;" ...它使你的查询更容易阅读,不是吗?b / b

(d)确保关闭并销毁记录集对象和完成后的

连接对象。

connstr =" Provider = Microsoft.Jet.OLEDB.4.0; Data Source =" &

Server.mapPath(" EmployeeTransactions.mdb")

设置Conn = CreateObject(" ADODB.Connection")

Conn .open connstr


''获取会话(loc)以查看是否允许他们更新记录

lloc = session(" sploctype" )

loccode = session(" splocationdesc")


accessupdate = 1

如果lloc =" School"然后accessupdate = 0

sql =" SELECT emprecid,employeeno,employeelastname,employeofirstname,

hrstatus,hrdate,budgetstatus,budgetdate,payrollstatus,payrolldate,

福利日,创建者,processstatus,employeesetype,location FROM

employeetransaction"


''我们只显示学校的记录位置

''否则,我们会显示所有部门


如果lloc =" School"然后

sql = sql& "其中location =''" &安培; loccode& "''和

((EmployeeTransaction.PayrollDate> =(date() - 30))或

(Isnull([EmployeeTransaction]。[PayrollDate])< ;> FALSE))通过emprecid命令

desc"

else

sql = sql& " where((EmployeeTransaction.PayrollDate> =(date() - 30))或

(Isnull([EmployeeTransaction]。[PayrollDate])<> FALSE))按照emprecid desc

设置rs = Conn.execute(sql)

....

response.write sb(rs(" hrstatus"))


function sb(s)

sb = s:如果len(trim(sb))= 0则sb ="& nbsp;"

结束函数


rs。 close:set rs = nothing

conn.close:set conn = nothing

-
http://www.aspfaq.com/

(反向回复地址。)



" wk6pack" <周*** @ sd61.bc.ca>在消息中写道

news:ed ************** @ TK2MSFTNGP09.phx.gbl ...
Several suggestions.

(a) don''t use Server.CreateObject, just CreateObject

(b) what is set rs = Server.CreateObject("ADODB.Recordset") for? You
override it later with set rs = AccessConn.execute(sql) ... I also changed
"AccessConn" to a more standard "Conn"...

(c) don''t do presentation things (replace null with "&nbsp;") in the query.
Do that where it belongs, in the presentation tier! Wherever you have a
value coming back from the resultset that needs to be at least "&nbsp;", use
the function I wrote below called sb (showblanks). Or, just response.write
rs("column") & "&nbsp;" ... it makes your query much easier to read, doesn''t
it?

(d) make sure you close and destroy both the recordset object and the
connection object after you''re done.
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.mapPath("EmployeeTransactions.mdb")
Set Conn = CreateObject("ADODB.Connection")
Conn.open connstr

''get session("loc") to see if they are allowed to update records
lloc = session("sploctype")
loccode = session("splocationdesc")

''Determining the ability to access update records
accessupdate = 1
if lloc = "School" then accessupdate = 0

sql = "SELECT emprecid, employeeno, employeelastname, employeefirstname,
hrstatus, hrdate, budgetstatus, budgetdate, payrollstatus, payrolldate,
benefitdate, createdby, processstatus, employeetype, location FROM
employeetransaction "

'' we only display the records for the school location
'' otherwise, we display all for departments

if lloc="School" then
sql = sql & " where location = ''" & loccode & "'' and
((EmployeeTransaction.PayrollDate >=(date()-30)) OR
(Isnull([EmployeeTransaction].[PayrollDate])<> FALSE)) order by emprecid
desc "
else
sql = sql & " where ((EmployeeTransaction.PayrollDate >= (date()-30)) OR
(Isnull([EmployeeTransaction].[PayrollDate])<>FALSE)) order by emprecid desc
"
end if

set rs = Conn.execute(sql)

....
response.write sb(rs("hrstatus"))

function sb(s)
sb = s : if len(trim(sb)) = 0 then sb = "&nbsp;"
end function

rs.close: set rs = nothing
conn.close: set conn = nothing
--
http://www.aspfaq.com/
(Reverse address to reply.)


"wk6pack" <wk***@sd61.bc.ca> wrote in message
news:ed**************@TK2MSFTNGP09.phx.gbl...

我间歇性地在我的asp页面上收到此错误。有一天它很好,有一天,它崩溃了很多。我已经搜索了这个网页和微软,他们说这是一个分配给会话变量的记录集。

我没有在我的代码中为会话变量分配任何记录集。我将
值分配给会话变量。
它似乎崩溃的地方是Set AccessConn =
Server.CreateObject(" ADODB.Connection")
代码:

connstr =" Provider = Microsoft.Jet.OLEDB.4.0; Data Source =" &
Server.mapPath(" EmployeeTransactions.mdb")
设置AccessConn = Server.CreateObject(" ADODB.Connection")
AccessConn.open connstr
''获取会话(loc)以查看是否允许他们更新记录
lloc = session(" sploctype")
loccode = session(" splocationdesc")

''确定访问更新记录的能力
如果lloc =" School"然后
accessupdate = 0

accessupdate = 1
结束如果

设置rs = Server.CreateObject(" ADODB.Recordset")
sql =" select emprecid,employeeno,employeelastname,employeefirstname,
iif(isnull(hrstatus),''& nbsp'',hrstatus)as hrstatus,
iif(isnull(hrdate), ''& nbsp'',hrdate)作为hrdate,
iif(isnull(budgetstatus),'& nbsp'',budgetstatus)作为budgetstatus,
iif(isnull(budgetdate),'' & nbsp'',budgetdate)as budgetdate," &安培; _
iif(isnull(payrollstatus),''& nbsp'',payrollstatus)作为payrollstatus,
iif(isnull(payrolldate),''& nbsp'',payrolldate)as payrolldate,
iif( isnull(benefitdate),''& nbsp'',benefitdate)as benefitdate,
iif(isnull(createdby),''& nbsp'',createdby)as createdby,
iif(isnull( processstatus),''& nbsp'',processstatus)作为processstatus,
employeesetype,来自employeetransaction的位置"

''我们只显示学校位置的记录否则,我们显示
所有部门
如果lloc =" School"然后
sql = sql& "其中location =''" &安培; loccode& "''和
((EmployeeTransaction.PayrollDate> =(date() - 30))或
(Isnull([EmployeeTransaction]。[PayrollDate])<> FALSE))排序依据emprecid
desc
其他
sql = sql& " where((EmployeeTransaction.PayrollDate> =(date() - 30))
OR(Isnull([EmployeeTransaction]。[PayrollDate])<> FALSE))按emprecid
desc命令
结束如果设置rs = AccessConn.execute(sql)

任何想法?
谢谢,

Hi,

I''m getting this error on my asp page intermittently. One day it is fine,
another day, it crashes a lot. I have searched the web and microsoft on
this and they say it is a recordset assigned to a session variable.

I dont assign any record sets to session variables in my code. I assign
values to the session variables though.
The place it seems to crash is Set AccessConn =
Server.CreateObject("ADODB.Connection")

code:

connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.mapPath("EmployeeTransactions.mdb")
Set AccessConn = Server.CreateObject("ADODB.Connection")
AccessConn.open connstr

''get session("loc") to see if they are allowed to update records
lloc = session("sploctype")
loccode = session("splocationdesc")

''Determining the ability to access update records
if lloc = "School" then
accessupdate = 0
else
accessupdate = 1
end if

Set rs = Server.CreateObject("ADODB.Recordset")
sql = "select emprecid, employeeno, employeelastname, employeefirstname,
iif(isnull(hrstatus),''&nbsp'',hrstatus) as hrstatus,
iif(isnull(hrdate),''&nbsp'',hrdate) as hrdate,
iif(isnull(budgetstatus),''&nbsp'',budgetstatus) as budgetstatus,
iif(isnull(budgetdate),''&nbsp'',budgetdate) as budgetdate," & _
" iif(isnull(payrollstatus),''&nbsp'',payrollstatus) as payrollstatus,
iif(isnull(payrolldate),''&nbsp'',payrolldate) as payrolldate,
iif(isnull(benefitdate),''&nbsp'',benefitdate) as benefitdate,
iif(isnull(createdby),''&nbsp'',createdby) as createdby,
iif(isnull(processstatus),''&nbsp'',processstatus) as processstatus,
employeetype, location from employeetransaction "

''we only display the records for the school location otherwise, we display
all for departments
if lloc="School" then
sql = sql & " where location = ''" & loccode & "'' and
((EmployeeTransaction.PayrollDate >=(date()-30)) OR
(Isnull([EmployeeTransaction].[PayrollDate])<> FALSE)) order by emprecid
desc "
else
sql = sql & " where ((EmployeeTransaction.PayrollDate >= (date()-30)) OR (Isnull([EmployeeTransaction].[PayrollDate])<>FALSE)) order by emprecid desc "
end if
set rs = AccessConn.execute(sql)

Any ideas??
thanks,
Will



Aaron [SQL Server MVP]写道:
Aaron [SQL Server MVP] wrote:
几条建议。

(a)不要用Server.CreateObject,只是CreateObject

(b)什么是设置rs = Server.CreateObject(" ADODB.Recordset")?你稍后用set rs = AccessConn.execute(sql)覆盖它...我还改变了AccessConn和AccessConn。更加标准的Conn......

(c)在
查询中不做演示文稿(用& nbsp;替换null)。在表示层中执行它所属的操作!
Several suggestions.

(a) don''t use Server.CreateObject, just CreateObject

(b) what is set rs = Server.CreateObject("ADODB.Recordset") for? You
override it later with set rs = AccessConn.execute(sql) ... I also
changed "AccessConn" to a more standard "Conn"...

(c) don''t do presentation things (replace null with "&nbsp;") in the
query. Do that where it belongs, in the presentation tier!




当我想使用GetString时,我在查询中执行此操作。


Bob Barrows

-

Microsoft MVP - ASP / ASP.NET

请回复新闻组。我的From

标题中列出的电子邮件帐户是我的垃圾邮件陷阱,因此我不经常检查它。通过发布到新闻组,您将获得更快的回复。



I do this in my query when I want to use GetString.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don''t check it very often. You will get a
quicker response by posting to the newsgroup.


有多少人在访问该网站?任何时候都存在与Access数据库相关的间歇性

错误,我会说它们经常与并发问题相关,并且访问不能/意味着要处理很多

的连接。


就你下面的代码而言,我会放弃Set rs =

Server.CreateObject(" ADODB.Recordset")行。你正在做的是创建

那里的空记录集,然后在Set rs = AccessConn.Execute(sql)

行,你正在摧毁记录集并创建一个新记录集。所以,那是额外处理时间的
微秒。


此外,我建议不要在你的查询中做所有IsNull的事情。 />
放弃所有这些。你可以做的是:


....

sql =" select emprecid,employeeno,employeelastname,

employeefirst,hrstatus,

hrdate,budgetstatus,budgetdate,payrollstatus,payro lldate,benefitdate,createdby ,, processstatus,

employeetype,employeeeransaction的位置"

....


然后,在你获得记录集之后,使用.GetRows将

记录集转储到数组中。 (然后快速关闭并销毁你的记录集和

ado连接!)使用GetRows方法,你可以将所有空值转换为

& nbsp;如此:


设置rs = AccessConn.Execute(sSQL)

如果不是rs.EOF那么aData = rs.GetRows(2 ,,," & nbsp;")

如果您不确定如何处理aData数组那么或者之前没有使用过

GetRows之前并且想要了解更多信息,请回到这里。


雷在工作

" wk6pack" <周*** @ sd61.bc.ca>在消息中写道

news:ed ************** @ TK2MSFTNGP09.phx.gbl ...
How many people are hitting the site? Any time there are "intermittent"
errors that are Access database related, I''d say that they are often related
to concurrency issues and Access not being able/meant to handle lots of
connections.

As far as the code you included below, I''d drop the Set rs =
Server.CreateObject("ADODB.Recordset") line. What you''re doing is creating
an empty recordset there, and then on the Set rs = AccessConn.Execute(sql)
line, you''re destroying the recordset and creating a new one. So, it''s a
microsecond of extra processing time there.

Also, instead of doing all that IsNull stuff in your query, I suggest
dropping all of that. What you can do instead is:

....
sql = "select emprecid, employeeno, employeelastname,
employeefirstname,hrstatus,
hrdate,budgetstatus,budgetdate,payrollstatus,payro lldate,benefitdate,createdby,,processstatus,
employeetype, location from employeetransaction "
....

And then, after you get your recordset back, use .GetRows to dump the
recordset into an array. (Then quickly close and destroy your recordset and
ado connection!) With the GetRows method, you can convert all the nulls to
&nbsp; as such:

Set rs = AccessConn.Execute(sSQL)
If Not rs.EOF Then aData = rs.GetRows(2,,,"&nbsp;")
If you aren''t sure what to do with the aData array then or haven''t used
GetRows before and would like to know more about it, just post back here.

Ray at work
"wk6pack" <wk***@sd61.bc.ca> wrote in message
news:ed**************@TK2MSFTNGP09.phx.gbl...


设置rs = Server.CreateObject(" ADODB.Recordset")
sql =" select emprecid,employeeno,employeelastname,employeofirstname,
iif(isnull(hrstatus),''& nbsp '',hrstatus)as hrstatus,
iif(isnull(hrdate),'& nbsp'',hrdate)as hrdate,
iif(isnull(budgetstatus),''& nbsp'' ,budgetstatus)as budgetstatus,
iif(isnull(budgetdate),''& nbsp'',budgetdate)as budgetdate," &安培; _
iif(isnull(payrollstatus),''& nbsp'',payrollstatus)作为payrollstatus,
iif(isnull(payrolldate),''& nbsp'',payrolldate)as payrolldate,
iif( isnull(benefitdate),''& nbsp'',benefitdate)as benefitdate,
iif(isnull(createdby),''& nbsp'',createdby)as createdby,
iif(isnull( processstatus),''& nbsp'',processstatus)作为processstatus,
employeesetype,来自employeetransaction的位置"

''我们只显示学校位置的记录否则,我们显示
所有部门
如果lloc =" School"然后
sql = sql& "其中location =''" &安培; loccode& "''和
((EmployeeTransaction.PayrollDate> =(date() - 30))或
(Isnull([EmployeeTransaction]。[PayrollDate])<> FALSE))排序依据emprecid
desc
其他
sql = sql& " where((EmployeeTransaction.PayrollDate> =(date() - 30))
(Isnull([EmployeeTransaction]。[PayrollDate])<> FALSE))按emprecid排序 desc
"
结束如果设置rs = AccessConn.execute(sql)


Set rs = Server.CreateObject("ADODB.Recordset")
sql = "select emprecid, employeeno, employeelastname, employeefirstname,
iif(isnull(hrstatus),''&nbsp'',hrstatus) as hrstatus,
iif(isnull(hrdate),''&nbsp'',hrdate) as hrdate,
iif(isnull(budgetstatus),''&nbsp'',budgetstatus) as budgetstatus,
iif(isnull(budgetdate),''&nbsp'',budgetdate) as budgetdate," & _
" iif(isnull(payrollstatus),''&nbsp'',payrollstatus) as payrollstatus,
iif(isnull(payrolldate),''&nbsp'',payrolldate) as payrolldate,
iif(isnull(benefitdate),''&nbsp'',benefitdate) as benefitdate,
iif(isnull(createdby),''&nbsp'',createdby) as createdby,
iif(isnull(processstatus),''&nbsp'',processstatus) as processstatus,
employeetype, location from employeetransaction "

''we only display the records for the school location otherwise, we display
all for departments
if lloc="School" then
sql = sql & " where location = ''" & loccode & "'' and
((EmployeeTransaction.PayrollDate >=(date()-30)) OR
(Isnull([EmployeeTransaction].[PayrollDate])<> FALSE)) order by emprecid
desc "
else
sql = sql & " where ((EmployeeTransaction.PayrollDate >= (date()-30))
OR
(Isnull([EmployeeTransaction].[PayrollDate])<>FALSE)) order by emprecid
desc
"
end if
set rs = AccessConn.execute(sql)






这篇关于“(null)”的Createobject导致异常C0000005的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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