Chong Posted April 15, 2003 Posted April 15, 2003 (edited) I have an error Data type mismatch in criteria expression when I run the application. Below are my codes. 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 Edited April 15, 2003 by Robby Quote
Moderators Robby Posted April 15, 2003 Moderators Posted April 15, 2003 I'm guessing intSSN and SSN (field) and Integers, if so, remove the single quotes surrounding intSSN. "....WHERE Education.SSN=" & intSSN Quote Visit...Bassic Software
Chong Posted April 15, 2003 Author Posted April 15, 2003 Thanks for trying to help me. Yes, the Education.SSN is a number. I did remove the quote around intSSN and here's the error I get: No value given for one or more required parameters. Thanks! Chong Quote
Moderators Robby Posted April 16, 2003 Moderators Posted April 16, 2003 are you sure that intSSN contains a value? do... messagebox.show(intSSN) Quote Visit...Bassic Software
Chong Posted April 16, 2003 Author Posted April 16, 2003 Thanks for helping me out. I'm 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 wasn't sure if this most efficient and best way to do it. Chong Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.