By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,226 Members | 1,435 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,226 IT Pros & Developers. It's quick & easy.

access in vb

P: 1
Expand|Select|Wrap|Line Numbers
  1. Imports System.Data.OleDb
  2. Public Class Form1
  3.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  4.         Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\palesa\Documents\studenttable.accdb")
  5.         Dim cmd As OleDbCommand = New OleDbCommand("select * from student where username = '" & txtusername.Text & "'and password = '" & txtpassword.Text & "' ", con)
  6.  
  7.         con.Open()
  8.         Dim sdr As OleDbDataReader = cmd.ExecuteReader()
  9.  
  10.         If sdr.Read = True Then
  11.             MsgBox("welcome")
  12.         Else : MsgBox("invalid")
  13.  
  14.         End If
im trying to retrieve data from access data base but i keep getting this message
Data type mismatch in criteria expression.
Nov 15 '11 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 1,221
Take a look at the table Student. The criteria expressions you are using compare username to textbox txtusername and password to textbox txtpassword.

Is one of those fields not data type text in the Student table?

Jim
Nov 16 '11 #2

NeoPa
Expert Mod 15k+
P: 31,707
Please see How to Debug SQL String. It will help us to help you.
Nov 17 '11 #3

Post your reply

Sign in to post your reply or Sign up for a free account.