473,325 Members | 2,712 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,325 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 2233
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.