Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6939691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:39:16+00:00 2026-05-27T12:39:16+00:00

I have an error ERROR [22018] [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in

  • 0

I have an error ERROR [22018] [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression. and I’ve been trying to solve this but unfortunately I couldn’t get the hack of this error. I’m a newbie in dotNet.

Public Sub LogInContinue(ByVal senter As Object, ByVal e As EventArgs)
    Dim LibDS As DataSet = New DataSet
    Dim LibDA As OdbcDataAdapter = New OdbcDataAdapter("SELECT * FROM tblUserAccount WHERE Uname='" & txtUserName.Text & "'", LibConn)
    Dim A As Integer
    LibDS.Tables.Add("tblUserAccount")
    A = LibDA.Fill(LibDS, "tblUserAccount")

    If A = 0 Then
        MessageBox.Show("Username you have supplied is invalid!" & vbCrLf & "Please click OK button to try again.", "INVALID USERNAME", MessageBoxButtons.OK, MessageBoxIcon.Error)
    Else
        If LibDS.Tables(0).Rows(0)("Uname") = Me.txtUserName.Text AndAlso LibDS.Tables(0).Rows(0)("Password") = Me.txtPassword.Text Then
            NewUserID.UUserID = LibDS.Tables(0).Rows(0)("UserID")
            UserAcceptedRole()
        Else
            MessageBox.Show("Password you have supplied is invalid." & vbCrLf & "Please try again!", "PASSWORD MISMATCHED", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
    End If
End Sub

Private Sub UserAcceptedRole()
    Dim ActualRole As String
    Dim LibDSa As DataSet = New DataSet
    Dim LibDAa As OdbcDataAdapter = New OdbcDataAdapter("SELECT * FROM tblRoles WHERE UserID='" & NewUserID.UUserID & "'", LibConn)
    LibDSa.Tables.Add("tblRoles")
    LibDAa.Fill(LibDSa, "tblRoles")

    ActualRole = LibDS.Tables(0).Rows(0)("Role").ToString
    If ActualRole = "Member" Then
        lblWelcome.Text = "Welcome " & txtUserName.Text
        NewObject.NewLabel(lblID, "You are logged in as " & ActualRole, "Calibri", 12, FontStyle.Regular, 666, 40)
        btnLogIn.Text = "Logout"
    End If
End Sub

The error is in the code LibDAa.Fill(LibDSa, "tblRoles") under the Private Sub UserAcceptedRole(). Kindly tell me what this error is all about? and if you have some advice for the improvement of my code(style), kindly tell me. Thanks loads.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:39:17+00:00Added an answer on May 27, 2026 at 12:39 pm

    Always use Parameters (Parameterized SQL statement). Read more on Parameters and SQL Injection.

    Private Sub UserAcceptedRole()
        Dim ActualRole As String
        Dim LibDt As New DataTable
        Dim Cmd As New OdbcCommand
        Cmd.CommandText="SELECT * FROM tblRoles WHERE UserID=@UserID"
        Cmd.Connection=LibConn
    
        MsgBox("Verifying the value of : " & NewUserID.UUserID)
    
        Cmd.Parameters.Add("@UserID",System.Data.Odbc.OdbcType.Int).Value=NewUserID.UUserID
    
        Dim LibDAa As OdbcDataAdapter = New OdbcDataAdapter(Cmd)
        LibDAa.Fill(LibDt)
    
        If LibDt.Rows.Count<>0 Then
    
          ActualRole = LibDt.Rows(0)("Role").ToString
    
          If ActualRole = "Member" Then
            lblWelcome.Text = "Welcome " & txtUserName.Text
            ....
          End If
        End If
    End Sub
    

    PS: You may use DataSet too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This time I have an error which I have been trying again to figure
I have error when I was parsing xml data. when we are converting xml
When I trying run Android Emulation, i Have error message: $ tools/emulator -avd Default
I want get data in db to listview. but it have error I cannot
Could You tell my why I have error 'Couldn't match expected type IO t
I have error: Cannot implicitly convert type 'string' to 'System.DateTime'a When I want get
We have an error that we can't seem to find and don't have the
I have an error handling method in my ApplicationController: rescue_from ActiveRecord::RecordNotFound, :with => :not_found
I have an error occuring frequently from our community server installation whenever the googlesitemap.ashx
I have this error message: Msg 8134, Level 16, State 1, Line 1 Divide

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.