Print Page | Close Window

Acces and asp.net

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Database Discussion
Forum Description: Discussion and chat on database related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=5712
Printed Date: 28 March 2026 at 7:50pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Acces and asp.net
Posted By: Diep-Vriezer
Subject: Acces and asp.net
Date Posted: 12 September 2003 at 3:58pm

Hey all,

I've got some sort of a problem, when I try the following: I want to compare an unique id to a field in the database, and then read another collum on that row. How is this done? I tried alot, but I kept recieving this kind of error:

Data type mismatch in criteria expression.

Sooow, how can I first be sure the unique id exists in the table (collum is called 'Uid'), and if so, retrieve the content of the collum next to it (collum is called 'Loggedin').

// Edit: Of course in ASP.NET



-------------
Gone..



Replies:
Posted By: Diep-Vriezer
Date Posted: 13 September 2003 at 4:34am
Alright, not really a clear question. How about this: I want to read a collumn named Loggedin on a row WHERE Uid = aUniqueId.
 
I made up the following code:

-------

Dim aConnection As OleDbConnection, aCommand As OleDbCommand, aDatareader As OleDbDataReader, aString As String

aConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Pub\wwwroot1\Components\Databases\Account.mdb;User Id=admin;Password=;")

aCommand = New OleDbCommand()

With aCommand

.CommandText = "SELECT * from tblLoggedin where Uid = '" & aUniqueId & "'"

.CommandType = CommandType.Text

.Connection = aConnection

End With

aConnection.Open()

aDatareader = aCommand.ExecuteReader()

While aDatareader.Read

aString = ""

aString = aDatareader.Item("Loggedin")

End While

aDatareader.Close()

aConnection.Close()

-------

Now I revieve the following error: (I just copied the entire error page )

-------

Server Error in '/' Application.

Data type mismatch in criteria expression.

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.Data.OleDb.OleDbException: Data type mismatch in criteria expression.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[OleDbException (0x80040e07): Data type mismatch in criteria expression.]
    System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandli ng(Int32 hr) +41
    System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleRe sult(tagDBPARAMS dbParams, Object& executeResult) +174
    System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& ; executeResult) +92
    System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavio r behavior, Object& executeResult) +65
    System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(Command Behavior behavior, String method) +112
   System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) +69
   System.Data.OleDb.OleDbCommand.ExecuteReader() +7
   denheijer.Account.CheckLoggedin(String aUniqueId, String cIp) in C:\Documents and Settings\Floris den Heijer\VSWebCache\DODGER\Components\Classes\Account.vb:32
   denheijer.Start.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\Floris den Heijer\VSWebCache\DODGER\Sections\Start\Start.aspx.vb:33
   System.Web.UI.Control.OnLoad(EventArgs e) +67
   System.Web.UI.Control.LoadRecursive() +35
   System.Web.UI.Page.ProcessRequestMain() +731



-------------
Gone..


Posted By: TYSON
Date Posted: 15 September 2003 at 8:14am

Try

.CommandText = "SELECT * from tblLoggedin where Uid = " & aUniqueId & ""



-------------
http://www.fuo-motorsports.com/ - http://www.fuo-motorsports.com/


Posted By: Diep-Vriezer
Date Posted: 15 September 2003 at 8:42am
Well, I already made it by simply changing the aUniqueId to the field it is in the database (an integer), and everything works fine now. Thanks anyway!

-------------
Gone..



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net