Results 1 to 6 of 6

Thread: [VS 2012] MYSQL DataAdapter.Fill gives KeyNotFoundException

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2007
    Location
    indiana
    Posts
    341

    [VS 2012] MYSQL DataAdapter.Fill gives KeyNotFoundException

    I have googled and tried to find an solution to this issue but I have had no luck. The code is meant to retrieve a list of tickets from a ticket database that have been created by a specific user.

    Code:
    Public Shared Function LoadTickets() As DataSet
            'dbhost, dbuser, dbpass are global variables that hold the server ip, username, and password rot the database
            Dim connstr As String = "server=" + dbHost + ";user=" + dbUser + ";database=tickets;port=3306;password=" + dbPass + ";"
            Dim conn As MySqlConnection = New MySqlConnection(connstr)
    
            'user is a public var that holds the current username
            Dim sql As String = "SELECT * FROM `ticket_index` WHERE username='" + User + "';"
    
    
            Dim daTicket As MySqlDataAdapter = New MySqlDataAdapter(sql, conn)
    
    
            Dim cb As MySqlCommandBuilder = New MySqlCommandBuilder(daTicket)
            cb.DataAdapter = daTicket
    
            Dim dsTicket As DataSet = New DataSet()
    
            'error is throw here
            daTicket.Fill(dsTicket, "ticket_index")
    
    
    
            Return dsTicket
    
    
        End Function
    The image below is the error I get when I try to pull the data from the Retrieve Data function in the server explorer or run any query on the connected database. Don't know if that will help but its here now.
    Name:  Capture.PNG
Views: 3130
Size:  8.1 KB
    I am at a loss, I have tweaked this code for a while now and can't come up with a solution. I am also kind of new to working with mysql databases and mysqldataadapters so any tips or advice is acceptable too. Thanks you for your time and for looking at my code
    Last edited by bagstoper; Nov 22nd, 2012 at 04:05 AM. Reason: posted the image

Posting Permissions

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



Click Here to Expand Forum to Full Width