473,396 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Type mismatch in .net query

Hi - I tried this in VS.Net, and also in the Web Matrix code below: -
but I am getting a type mismatch error.

The sql statement runs perfectly from within the Access Query Designer.

Can anyone verify the syntax, and that my .net code is ok - the type
mismatch is happening at: DataGrid1.DataSource =
myCommand.ExecuteReader(CommandBehavior.CloseConne ction)

Thanks in advance,


<%@ Page Language="VB" debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDB" %>
<script runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
Dim ConnectionString As String =
"Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data
Source=C:\dbweb\clearblue2.mdb"
Dim CommandText As String = "SELECT
IIf(Sum(G1_PossScore)=0,0,Int(Sum(G1_Score)/Sum(G1_PossScore)*100)) AS
G1, Temps.Name FROM tblkbmonitor LEFT JOIN Temps ON
tblkbmonitor.ddlAuthor = Temps.T_ID GROUP BY Temps.Name;"
Dim myConnection As New OleDBConnection(ConnectionString)
Dim myCommand As New OleDBCommand(CommandText, myConnection)
myConnection.Open()
DataGrid1.DataSource =
myCommand.ExecuteReader(CommandBehavior.CloseConne ction)
DataGrid1.DataBind()
End Sub
</script>

<html>
<head>
</head>
<body style="FONT-FAMILY: arial">
<h2>Simple Data Report
</h2>
<hr size="1" />
<form runat="server">
<asp:datagrid id="DataGrid1" runat="server" CellSpacing="1"
GridLines="None" CellPadding="3" BackColor="White" ForeColor="Black"
EnableViewState="False">
<HeaderStyle font-bold="True" forecolor="white"
backcolor="#4A3C8C"></HeaderStyle>
<ItemStyle backcolor="#DEDFDE"></ItemStyle>
</asp:datagrid>
</form>
</body>
</html>


Stacktrace:

[OleDbException (0x80004005): Type mismatch in expression.]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(Int32
hr) +41

System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPA
RAMS dbParams, Object& executeResult) +174
System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object&
executeResult) +92
System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior
behavior, Object& executeResult) +65
System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior
behavior, String method) +112
System.Data.OleDb.OleDbCommand.ExecuteReader(Comma ndBehavior
behavior) +69
ASP.test3_aspx.Page_Load(Object Sender, EventArgs E) in
C:\Inetpub\wwwroot\aspxtest\test3.aspx:20
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #1
1 2238
Mark <an*******@devdex.com> wrote in message news:<#0**************@TK2MSFTNGP11.phx.gbl>...
Hi - I tried this in VS.Net, and also in the Web Matrix code below: -
but I am getting a type mismatch error.

The sql statement runs perfectly from within the Access Query Designer.

Can anyone verify the syntax, and that my .net code is ok - the type
mismatch is happening at: DataGrid1.DataSource =
myCommand.ExecuteReader(CommandBehavior.CloseConne ction)

Thanks in advance,


<%@ Page Language="VB" debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDB" %>
<script runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
Dim ConnectionString As String =
"Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data
Source=C:\dbweb\clearblue2.mdb"
Dim CommandText As String = "SELECT
IIf(Sum(G1_PossScore)=0,0,Int(Sum(G1_Score)/Sum(G1_PossScore)*100)) AS
G1, Temps.Name FROM tblkbmonitor LEFT JOIN Temps ON
tblkbmonitor.ddlAuthor = Temps.T_ID GROUP BY Temps.Name;"
Dim myConnection As New OleDBConnection(ConnectionString)
Dim myCommand As New OleDBCommand(CommandText, myConnection)
myConnection.Open()
DataGrid1.DataSource =
myCommand.ExecuteReader(CommandBehavior.CloseConne ction)
DataGrid1.DataBind()
End Sub
</script>

<html>
<head>
</head>
<body style="FONT-FAMILY: arial">
<h2>Simple Data Report
</h2>
<hr size="1" />
<form runat="server">
<asp:datagrid id="DataGrid1" runat="server" CellSpacing="1"
GridLines="None" CellPadding="3" BackColor="White" ForeColor="Black"
EnableViewState="False">
<HeaderStyle font-bold="True" forecolor="white"
backcolor="#4A3C8C"></HeaderStyle>
<ItemStyle backcolor="#DEDFDE"></ItemStyle>
</asp:datagrid>
</form>
</body>
</html>


Stacktrace:

[OleDbException (0x80004005): Type mismatch in expression.]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(Int32
hr) +41

System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPA
RAMS dbParams, Object& executeResult) +174
System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object&
executeResult) +92
System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior
behavior, Object& executeResult) +65
System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior
behavior, String method) +112
System.Data.OleDb.OleDbCommand.ExecuteReader(Comma ndBehavior
behavior) +69
ASP.test3_aspx.Page_Load(Object Sender, EventArgs E) in
C:\Inetpub\wwwroot\aspxtest\test3.aspx:20
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Try using ";" instead of "," in the IIF function for separating arguments
Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Arun Wadhawan | last post by:
Hello MY SQL Server is causing me this problem : Microsoft VBScript runtime error '800a000d' Type mismatch: 'ident' >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> I am getting from...
3
by: Laurel | last post by:
this is driving me crazy. i need to use a form control as a criteria in a select query, and the control's value is set depending upon what a user selects in an option group on the form. the query...
6
by: Faz | last post by:
I am trying to do a simple query between two tables which come from an ODBC (oracle) database, so I cannot change the data type of these values. I am trying to do a join between a field...
3
by: Faz | last post by:
Even after changing Invoice_ID to Clng(Invoice_ID) and trying to link to the Reference_2 field which is text it is giving me a type mismatch error. So I created a new query in access where I...
0
by: news.paradise.net.nz | last post by:
I have been developing access databases for over 5 years. I have a large database and I have struck this problem with it before but can find nothing in help or online. Access 2000 I have a query...
1
by: ArcadeJr | last post by:
Good morning all! I have been getting a Run-time Error message #3464 - Data Type mismatch in criteria expression. While trying to run a query. I have a database where the field Asset_Number...
1
by: Mark | last post by:
Hi - I tried this in VS.Net, and also in the Web Matrix code below: - but I am getting a type mismatch error. The sql statement runs perfectly from within the Access Query Designer. Can anyone...
2
by: igor.barbaric | last post by:
Hello! I have created a very simple query like this: SELECT Tasks.Name, DurationHrs(,) AS Duration FROM Tasks INNER JOIN Log ON Tasks.TaskID=Log.TaskID; The above query works fine....
19
by: Lysander | last post by:
I have written a query that takes three integers representing day,month and year, forms a date from them and compares this date to the date the record was entered and returns any records where the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.