Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Acces and asp.net
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Acces and asp.net

 Post Reply Post Reply Page  12>
Author
Diep-Vriezer View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
Post Options Post Options   Thanks (0) Thanks(0)   Quote Diep-Vriezer Quote  Post ReplyReply Direct Link To This Post Topic: Acces and asp.net
    Posted: 12 September 2003 at 3:59pm

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



Edited by Diep-Vriezer
Gone..
Back to Top
Diep-Vriezer View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
Post Options Post Options   Thanks (0) Thanks(0)   Quote Diep-Vriezer Quote  Post ReplyReply Direct Link To This Post 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..
Back to Top
otaku View Drop Down
Newbie
Newbie


Joined: 01 June 2003
Location: Canada
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote otaku Quote  Post ReplyReply Direct Link To This Post Posted: 14 September 2003 at 12:28pm

aUniqueId is a integer, not a string that's why you get "Data type mismatch" error message,
use this instead:


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

Back to Top
Diep-Vriezer View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
Post Options Post Options   Thanks (0) Thanks(0)   Quote Diep-Vriezer Quote  Post ReplyReply Direct Link To This Post Posted: 14 September 2003 at 3:07pm
Are you sure? The aUniqueId is a string wich I set before. But, I'll try and add .GetType.ToString after the aUniqueId.
Gone..
Back to Top
Diep-Vriezer View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
Post Options Post Options   Thanks (0) Thanks(0)   Quote Diep-Vriezer Quote  Post ReplyReply Direct Link To This Post Posted: 14 September 2003 at 3:08pm

 Weird, but it works and I feel so enormous dumb now, you have no idea..

Gone..
Back to Top
Diep-Vriezer View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
Post Options Post Options   Thanks (0) Thanks(0)   Quote Diep-Vriezer Quote  Post ReplyReply Direct Link To This Post Posted: 14 September 2003 at 3:15pm

O no!

Exactly the same error.. This is my code:

Public aIsLoggedin As Boolean, aIsIpBanned As Boolean, aIsAccountBanned As Boolean, aString As String

Public Function CheckLoggedin(ByVal aUniqueId As String, ByVal cIp As String)

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

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.GetType.ToString & "'"

.CommandType = CommandType.Text

.Connection = aConnection

End With

aConnection.Open()

aDatareader = aCommand.ExecuteReader()

While aDatareader.Read

aString = aDatareader.GetString(1)

End While

aConnection.Close()

End Function

The bold thing is where it all goes wrong... The aUniqueId exists in the database, and I want to retrieve the data of a column named Loggedin.

Gone..
Back to Top
otaku View Drop Down
Newbie
Newbie


Joined: 01 June 2003
Location: Canada
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote otaku Quote  Post ReplyReply Direct Link To This Post Posted: 14 September 2003 at 4:19pm

Sorry I said aUniqueId, I wanted to say Uid is a integer

If in your database Uid is an integer (as I think ):

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

But if in your database Uid is a String:

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

Back to Top
Diep-Vriezer View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
Post Options Post Options   Thanks (0) Thanks(0)   Quote Diep-Vriezer Quote  Post ReplyReply Direct Link To This Post Posted: 15 September 2003 at 12:09am
 I got it now, well aUniqueId is an autonumber gererated by Acces, so I guess an Integer.
Gone..
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.