Data type mismatch

Chong

Well-known member
Joined
Apr 4, 2003
Messages
79
I have an error Data type mismatch in criteria expression when I run the application. Below are my codes.

Code:
Private Shared mdbPath As String = Application.StartupPath & "\Scholarship.mdb"

Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mdbPath
Dim strSQL As String
Dim rdrEdu As OleDbDataReader
Dim cn As New OleDbConnection(strConn)

cn.Open()
strSQL = "SELECT SSN, Status, HghSchoolGPA, ACT, SAT," & _
       "TotalCredits, GPALstSemester, GPACumulative, Rank " & _
        "FROM Education WHERE Education.SSN=" & "" & intSSN & ""

Dim cmdSQL As New OleDbCommand(strSQL, cn)

Try
	rdrEdu = cmdSQL.ExecuteReader
   Catch dbException As System.Data.OleDb.OleDbException
	MessageBox.Show(dbException.Message)
End Try

Please help.

Many thanks in advance.

Chong
 
Last edited by a moderator:
Im guessing intSSN and SSN (field) and Integers, if so, remove the single quotes surrounding intSSN.
Code:
"....WHERE Education.SSN=" & intSSN
 
Thanks for trying to help me.

Yes, the Education.SSN is a number. I did remove the quote around intSSN and heres the error I get:

No value given for one or more required parameters.

Thanks!

Chong
 
Thanks for helping me out. Im greatly appreciated. Actually I found out that I never did call the rdr.Read in my code. Currenly I have been using this:

While rdr.Read
schlrHolder = rdr("SSN")
End While

But I wasnt sure if this most efficient and best way to do it.

Chong
 
Back
Top