DISP_E_TYPEMISMATCH with OWC11

G

Guest

Hi,
Does anyone have any idea what I am doing wrong here. I have a SQL query
that pulls some data from a database and I want to display it as a graph.
Here is the code snippet:

Dim objChartspace, objChart, c, objConn, objRS, axis, sql
objChartspace = Server.CreateObject("owc11.Chartspace")
objConn = Server.CreateObject("OWC11.DataSourceControl")
objConn.ConnectionString = Application("AMS")
objChart = objChartspace.Charts.Add
c = objChartspace.Constants
objChart.Type = c.chChartTypeLine
objChart.HasLegend = True
sql = "Select Workgroup, day(lastModifiedOn) as entryMonth, count(*)
as _
entryTotals from vw_UnBilledEntries group by workgroup,
day(lastModifiedOn)"
objConn.RecordsetDefs.AddNew(sql)
objChartspace.DataSource = objRS
objChart.SetData(c.chDimSeriesNames, 0, "Workgroup")
objChart.SetData(c.chDimCategories, 0, "entryMonth")
objChart.SetData(c.chDimValues, 0, "entryTotals")
For Each axis In objChart.Axes
axis.HasTitle = True
If axis.Type = c.chCategoryAxis Then
axis.Title.Caption = "entryMonth"
Else
axis.Title.Caption = "entryTotals"
End If
Next
objChartspace.ExportPicture(Server.MapPath("/images/amschart"),
"gif", 600, 350)
Response.Write("<img src=""\images\amschart.gif"">")

However I get this error:

Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Type
mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))

Source Error:

Line 55: sql = "Select Workgroup, day(lastModifiedOn) as entryMonth,
count(*) as entryTotals from vw_UnBilledEntries group by workgroup,
day(lastModifiedOn)"
Line 56: objConn.RecordsetDefs.AddNew(sql)
Line 57: objChartspace.DataSource = objRS
Line 58: objChart.SetData(c.chDimSeriesNames, 0, "Workgroup")
Line 59: objChart.SetData(c.chDimCategories, 0, "entryMonth")


Anyone have any words of wisdom?

Thanks,
Steve
 
G

Guest

Alvin - thanks for replying. The SQL string works without a hitch. Do you
think its related to what data type OWC is expecting from the SQL output,
but its not getting that data type?

Thanks,
Steve

Alvin Bruney - ASP.NET MVP said:
this is a sql error not owc

--
Warm Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley 2006
Blog: http://msmvps.com/blogs/Alvin/
-------------------------------------------------------



Hi,
Does anyone have any idea what I am doing wrong here. I have a SQL query
that pulls some data from a database and I want to display it as a graph.
Here is the code snippet:

Dim objChartspace, objChart, c, objConn, objRS, axis, sql
objChartspace = Server.CreateObject("owc11.Chartspace")
objConn = Server.CreateObject("OWC11.DataSourceControl")
objConn.ConnectionString = Application("AMS")
objChart = objChartspace.Charts.Add
c = objChartspace.Constants
objChart.Type = c.chChartTypeLine
objChart.HasLegend = True
sql = "Select Workgroup, day(lastModifiedOn) as entryMonth, count(*)
as _
entryTotals from vw_UnBilledEntries group by workgroup,
day(lastModifiedOn)"
objConn.RecordsetDefs.AddNew(sql)
objChartspace.DataSource = objRS
objChart.SetData(c.chDimSeriesNames, 0, "Workgroup")
objChart.SetData(c.chDimCategories, 0, "entryMonth")
objChart.SetData(c.chDimValues, 0, "entryTotals")
For Each axis In objChart.Axes
axis.HasTitle = True
If axis.Type = c.chCategoryAxis Then
axis.Title.Caption = "entryMonth"
Else
axis.Title.Caption = "entryTotals"
End If
Next
objChartspace.ExportPicture(Server.MapPath("/images/amschart"),
"gif", 600, 350)
Response.Write("<img src=""\images\amschart.gif"">")

However I get this error:

Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Type
mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))

Source Error:

Line 55: sql = "Select Workgroup, day(lastModifiedOn) as entryMonth,
count(*) as entryTotals from vw_UnBilledEntries group by workgroup,
day(lastModifiedOn)"
Line 56: objConn.RecordsetDefs.AddNew(sql)
Line 57: objChartspace.DataSource = objRS
Line 58: objChart.SetData(c.chDimSeriesNames, 0, "Workgroup")
Line 59: objChart.SetData(c.chDimCategories, 0, "entryMonth")


Anyone have any words of wisdom?

Thanks,
Steve
 
A

Alvin Bruney

Line 56, you need to pass the two parameters to the addnew function of the
datasource control.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------

Alvin - thanks for replying. The SQL string works without a hitch. Do
you think its related to what data type OWC is expecting from the SQL
output, but its not getting that data type?

Thanks,
Steve

Alvin Bruney - ASP.NET MVP said:
this is a sql error not owc

--
Warm Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley 2006
Blog: http://msmvps.com/blogs/Alvin/
-------------------------------------------------------



Hi,
Does anyone have any idea what I am doing wrong here. I have a SQL
query
that pulls some data from a database and I want to display it as a
graph.
Here is the code snippet:

Dim objChartspace, objChart, c, objConn, objRS, axis, sql
objChartspace = Server.CreateObject("owc11.Chartspace")
objConn = Server.CreateObject("OWC11.DataSourceControl")
objConn.ConnectionString = Application("AMS")
objChart = objChartspace.Charts.Add
c = objChartspace.Constants
objChart.Type = c.chChartTypeLine
objChart.HasLegend = True
sql = "Select Workgroup, day(lastModifiedOn) as entryMonth, count(*)
as _
entryTotals from vw_UnBilledEntries group by workgroup,
day(lastModifiedOn)"
objConn.RecordsetDefs.AddNew(sql)
objChartspace.DataSource = objRS
objChart.SetData(c.chDimSeriesNames, 0, "Workgroup")
objChart.SetData(c.chDimCategories, 0, "entryMonth")
objChart.SetData(c.chDimValues, 0, "entryTotals")
For Each axis In objChart.Axes
axis.HasTitle = True
If axis.Type = c.chCategoryAxis Then
axis.Title.Caption = "entryMonth"
Else
axis.Title.Caption = "entryTotals"
End If
Next
objChartspace.ExportPicture(Server.MapPath("/images/amschart"),
"gif", 600, 350)
Response.Write("<img src=""\images\amschart.gif"">")

However I get this error:

Type mismatch. (Exception from HRESULT: 0x80020005
(DISP_E_TYPEMISMATCH))
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Type
mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))

Source Error:

Line 55: sql = "Select Workgroup, day(lastModifiedOn) as entryMonth,
count(*) as entryTotals from vw_UnBilledEntries group by workgroup,
day(lastModifiedOn)"
Line 56: objConn.RecordsetDefs.AddNew(sql)
Line 57: objChartspace.DataSource = objRS
Line 58: objChart.SetData(c.chDimSeriesNames, 0, "Workgroup")
Line 59: objChart.SetData(c.chDimCategories, 0, "entryMonth")


Anyone have any words of wisdom?

Thanks,
Steve
 

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

Top