Error while update data in DataGridView from MYSQL

Posted on 2012-09-20
Last Modified: 2012-09-21
Hi ,

i am facing error while try out select data from mysql to DGV, my command as follows: -

cmd = "Select Top 200 idMasterSMSdB as [No],Sender as [Sender],TimeRec as [Time],MsgDataIn as [InComing SMS],MsgDataOut as [OutGoing SMS],Status as [Status]From mastersmsdb order by No desc";

 da.SelectCommand = new MySqlCommand(cmd, myconint);

            da.Fill(ds, "mastersmsdb");
            DG1.DataSource = ds.Tables["mastersmsdb"];
            bs.DataSource = ds.Tables["mastersmsdb"];
Question by:TITO2009
    LVL 24

    Assisted Solution

    MySQL doesn't accept "Select top 200".  Use "limit 200" at the end (after "order by No desc") instead.
    LVL 24

    Accepted Solution

    also, you can't use the brackets to identify columns without some tweaking. Out of the box, your query should look like this:

    SELECT idMasterSMSdB AS `No`,
    Sender AS Sender,TimeRec AS `Time`,
    MsgDataIn AS `InComing SMS`,
    MsgDataOut AS `OutGoing SMS`,
    Status AS `Status`
    FROM mastersmsdb ORDER BY `NO` DESC
    LIMIT 200;

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
    I have been using r1soft Continuous Data Protection ( for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now