Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2008

    Unanswered: Query not working

    I am using Visual Web developer 2008 with backend as Microsoft Access
    I am trying to execute query from the table but not returning the values.
    In Student table the fields are UserID(PrimaryKey), UserName, UserPwd.
    I executed the query to select these 3 values if the provided values in textbox1 and textbox2 matches and to return in label1,label2,label3.
    When i try query alone with UserName and UserPwd it is returning values, but not when i query for all the 3.
                Dim strSQL As String = "select UserID,UserName,UserPwd from tbl_createuser where UserName=? and UserPwd=?"
                Dim cmd As New OleDbCommand(strSQL, DataConn)
                Dim dr As OleDbDataReader
                cmd.Parameters.AddWithValue("UserName", TextBox1.Text)
                cmd.Parameters.AddWithValue("UserPwd", TextBox2.Text)
                dr = cmd.ExecuteReader
                If dr.HasRows Then
                    Label1.Text = dr("UserName")
                    Label2.Text = dr("UserPwd")
                    Label3.Text = dr("UserID")
                End If
            Catch ex As Exception
            End Try
        End Sub
    After the query is executed it displays error as "No data exists for rows/colums". But i am having the rows.

  2. #2
    Join Date
    Oct 2009
    first step is a sanity check; query directly in the Access db itself, use normal query design, manually putting in the values of the 3 textboxes....and verify that the query that you are attempting to send in from Visual Web actually does result in records when implemented in pure Access alone....

    queries are never wrong - they may not be what you expect or want - but they are never wrong.....

    in this case you have to sanity check the query stand alone inside Access - if it works then you do have a syntax issue in your visual code - - you may need to go to a visual forum for that kind of assist.....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts