asp to asp.net error

A

amitbadgi

Hi I am converting an asp applicattion to asp.net, and I am getting an
error as follows,
Exception Details: System.Runtime.InteropServices.COMException: Type
mismatch.

Source Error:


Line 350: 'response.Write(sql2)
Line 351: rs_getAlarmCount =
Server.CreateObject("ADODB.Recordset")
Line 352: rs_getAlarmCount.ActiveConnection = MM_rs_PAVE_CC_1_STRING
Line 353: rs_getAlarmCount.Source = sql
Line 354: rs_getAlarmCount.CursorType = 0


Source File: C:\Documents and
Settings\amit\Desktop\WebSite1\reports\campusfiresafetyreport.aspx
Line: 352

Stack Trace:


[COMException (0x80020005): Type mismatch.]

Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateSet(Object
o, Type& objType, String name, Object[] args, String[] paramnames,
Boolean OptimisticSet, CallType UseCallType) +2138
Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateSet(Object
Instance, Type Type, String MemberName, Object[] Arguments, String[]
ArgumentNames, Type[] TypeArguments, Boolean OptimisticSet, Boolean
RValueBase, CallType CallType) +180
Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateSet(Object
Instance, Type Type, String MemberName, Object[] Arguments, String[]
ArgumentNames, Type[] TypeArguments) +33
ASP.campusfiresafetyreport_aspx.getAlarmCount(Object location,
Object alarmtype, Object thisyear) in C:\Documents and
Settings\amit\Desktop\WebSite1\reports\campusfiresafetyreport.aspx:352
ASP.campusfiresafetyreport_aspx.__Render__control1(HtmlTextWriter
__w, Control parameterContainer) in C:\Documents and
Settings\amit\Desktop\WebSite1\reports\campusfiresafetyreport.aspx:251
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,
ICollection children) +98
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
System.Web.UI.Page.Render(HtmlTextWriter writer) +27
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer,
ControlAdapter adapter) +53
System.Web.UI.Control.RenderControl(HtmlTextWriter writer,
ControlAdapter adapter) +280
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +24
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+8878


The code above is defined as follows
<Script type="VB" runat="Server">

function getAlarmCount(location, alarmtype, thisyear)

Dim sql = " SELECT COUNT(*) AS realalarmcount " & _
"FROM (tblEvent INNER JOIN tblEvent_type ON tblEvent.case_no =
tblEvent_type.case_no) " & _
"WHERE (tblEvent_type.event_type_id = "& alarmtype &") " & _
" AND (tblEvent.date_of_event > '1/1/"& thisyear &"' and
tblEvent.date_of_event < '12/31/"& thisyear &"' ) "
if location <> "0" then
sql = sql & " AND (tblEvent.location = "& location &") "
end if

'response.Write(sql2)
rs_getAlarmCount = Server.CreateObject("ADODB.Recordset")
rs_getAlarmCount.ActiveConnection = MM_rs_PAVE_CC_1_STRING
rs_getAlarmCount.Source = sql
rs_getAlarmCount.CursorType = 0
rs_getAlarmCount.CursorLocation = 2
rs_getAlarmCount.LockType = 1
rs_getAlarmCount.Open()

alarmcount = rs_getAlarmCount("realalarmcount")

'.response.Write(alarmcount)

rs_getAlarmCount.Close()
rs_getAlarmCount = Nothing

getAlarmCount = alarmcount

end function
</Script>

The active connection is used elsewhere too and is workign fine, but
when its defined in teh script block, its giving me an error, i donot
know how to fix it, I need help. thanks




--------------------------------------------------------------------------------
 
M

Mark Fitzpatrick

Your best bet is to use the native .Net Framework types. What's happening
here is you are still using the old ADODB.Recordset object, which is an
unmanaged reference. You're better off using a SqlDataReader or
OleDbDataReader to get the job done as those are native types. When you get
a reference to the recordset object here, it doesn't exactly know what to do
wiht it in line 352 because it has no type information specific to the
Recordset object, only the generic type information for the type returned by
server.createobject.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

Hi I am converting an asp applicattion to asp.net, and I am getting an
error as follows,
Exception Details: System.Runtime.InteropServices.COMException: Type
mismatch.

Source Error:


Line 350: 'response.Write(sql2)
Line 351: rs_getAlarmCount =
Server.CreateObject("ADODB.Recordset")
Line 352: rs_getAlarmCount.ActiveConnection = MM_rs_PAVE_CC_1_STRING
Line 353: rs_getAlarmCount.Source = sql
Line 354: rs_getAlarmCount.CursorType = 0


Source File: C:\Documents and
Settings\amit\Desktop\WebSite1\reports\campusfiresafetyreport.aspx
Line: 352

Stack Trace:


[COMException (0x80020005): Type mismatch.]

Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateSet(Object
o, Type& objType, String name, Object[] args, String[] paramnames,
Boolean OptimisticSet, CallType UseCallType) +2138
Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateSet(Object
Instance, Type Type, String MemberName, Object[] Arguments, String[]
ArgumentNames, Type[] TypeArguments, Boolean OptimisticSet, Boolean
RValueBase, CallType CallType) +180
Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateSet(Object
Instance, Type Type, String MemberName, Object[] Arguments, String[]
ArgumentNames, Type[] TypeArguments) +33
ASP.campusfiresafetyreport_aspx.getAlarmCount(Object location,
Object alarmtype, Object thisyear) in C:\Documents and
Settings\amit\Desktop\WebSite1\reports\campusfiresafetyreport.aspx:352
ASP.campusfiresafetyreport_aspx.__Render__control1(HtmlTextWriter
__w, Control parameterContainer) in C:\Documents and
Settings\amit\Desktop\WebSite1\reports\campusfiresafetyreport.aspx:251
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,
ICollection children) +98
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
System.Web.UI.Page.Render(HtmlTextWriter writer) +27
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer,
ControlAdapter adapter) +53
System.Web.UI.Control.RenderControl(HtmlTextWriter writer,
ControlAdapter adapter) +280
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +24
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+8878


The code above is defined as follows
<Script type="VB" runat="Server">

function getAlarmCount(location, alarmtype, thisyear)

Dim sql = " SELECT COUNT(*) AS realalarmcount " & _
"FROM (tblEvent INNER JOIN tblEvent_type ON tblEvent.case_no =
tblEvent_type.case_no) " & _
"WHERE (tblEvent_type.event_type_id = "& alarmtype &") " & _
" AND (tblEvent.date_of_event > '1/1/"& thisyear &"' and
tblEvent.date_of_event < '12/31/"& thisyear &"' ) "
if location <> "0" then
sql = sql & " AND (tblEvent.location = "& location &") "
end if

'response.Write(sql2)
rs_getAlarmCount = Server.CreateObject("ADODB.Recordset")
rs_getAlarmCount.ActiveConnection = MM_rs_PAVE_CC_1_STRING
rs_getAlarmCount.Source = sql
rs_getAlarmCount.CursorType = 0
rs_getAlarmCount.CursorLocation = 2
rs_getAlarmCount.LockType = 1
rs_getAlarmCount.Open()

alarmcount = rs_getAlarmCount("realalarmcount")

'.response.Write(alarmcount)

rs_getAlarmCount.Close()
rs_getAlarmCount = Nothing

getAlarmCount = alarmcount

end function
</Script>

The active connection is used elsewhere too and is workign fine, but
when its defined in teh script block, its giving me an error, i donot
know how to fix it, I need help. thanks
 
P

Pat

Old ADO objects like recordset aren't supported by asp.net
try looking through Datareader,Dataset
Actually Datareader replaces RecordSet
Hope that helps
PAtrick

Hi I am converting an asp applicattion to asp.net, and I am getting an
error as follows,
Exception Details: System.Runtime.InteropServices.COMException: Type
mismatch.

Source Error:


Line 350: 'response.Write(sql2)
Line 351: rs_getAlarmCount =
Server.CreateObject("ADODB.Recordset")
Line 352: rs_getAlarmCount.ActiveConnection = MM_rs_PAVE_CC_1_STRING
Line 353: rs_getAlarmCount.Source = sql
Line 354: rs_getAlarmCount.CursorType = 0


Source File: C:\Documents and
Settings\amit\Desktop\WebSite1\reports\campusfiresafetyreport.aspx
Line: 352

Stack Trace:


[COMException (0x80020005): Type mismatch.]

Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateSet(Object
o, Type& objType, String name, Object[] args, String[] paramnames,
Boolean OptimisticSet, CallType UseCallType) +2138
Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateSet(Object
Instance, Type Type, String MemberName, Object[] Arguments, String[]
ArgumentNames, Type[] TypeArguments, Boolean OptimisticSet, Boolean
RValueBase, CallType CallType) +180
Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateSet(Object
Instance, Type Type, String MemberName, Object[] Arguments, String[]
ArgumentNames, Type[] TypeArguments) +33
ASP.campusfiresafetyreport_aspx.getAlarmCount(Object location,
Object alarmtype, Object thisyear) in C:\Documents and
Settings\amit\Desktop\WebSite1\reports\campusfiresafetyreport.aspx:352
ASP.campusfiresafetyreport_aspx.__Render__control1(HtmlTextWriter
__w, Control parameterContainer) in C:\Documents and
Settings\amit\Desktop\WebSite1\reports\campusfiresafetyreport.aspx:251
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,
ICollection children) +98
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
System.Web.UI.Page.Render(HtmlTextWriter writer) +27
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer,
ControlAdapter adapter) +53
System.Web.UI.Control.RenderControl(HtmlTextWriter writer,
ControlAdapter adapter) +280
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +24
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+8878


The code above is defined as follows
<Script type="VB" runat="Server">

function getAlarmCount(location, alarmtype, thisyear)

Dim sql = " SELECT COUNT(*) AS realalarmcount " & _
"FROM (tblEvent INNER JOIN tblEvent_type ON tblEvent.case_no =
tblEvent_type.case_no) " & _
"WHERE (tblEvent_type.event_type_id = "& alarmtype &") " & _
" AND (tblEvent.date_of_event > '1/1/"& thisyear &"' and
tblEvent.date_of_event < '12/31/"& thisyear &"' ) "
if location <> "0" then
sql = sql & " AND (tblEvent.location = "& location &") "
end if

'response.Write(sql2)
rs_getAlarmCount = Server.CreateObject("ADODB.Recordset")
rs_getAlarmCount.ActiveConnection = MM_rs_PAVE_CC_1_STRING
rs_getAlarmCount.Source = sql
rs_getAlarmCount.CursorType = 0
rs_getAlarmCount.CursorLocation = 2
rs_getAlarmCount.LockType = 1
rs_getAlarmCount.Open()

alarmcount = rs_getAlarmCount("realalarmcount")

'.response.Write(alarmcount)

rs_getAlarmCount.Close()
rs_getAlarmCount = Nothing

getAlarmCount = alarmcount

end function
</Script>

The active connection is used elsewhere too and is workign fine, but
when its defined in teh script block, its giving me an error, i donot
know how to fix it, I need help. thanks




-------------------------------------------------------------------------- ------
 
A

amitbadgi

Thanks for teh reply guys, But the problem is that its working
everywhere else, except in this block which I had mentioned, now I just
want this to wrk on temporary basis, and I donot understand why it
works everywhere else except here, is it becoz its defined in teh
following block
<script type="vb" runat="server">
</script>
I need help, as i need to complete it asap. Any help is appreciated
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top