• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 619
  • Last Modified:

Error while update data in DataGridView from MYSQL

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);

            myconint.Open();
            ds.Clear();
            da.Fill(ds, "mastersmsdb");
            DG1.DataSource = ds.Tables["mastersmsdb"];
            bs.DataSource = ds.Tables["mastersmsdb"];
            myconint.Close();
MYSQL.JPG
0
Ramanathan Tito Titan Nadar
Asked:
Ramanathan Tito Titan Nadar
2 Solutions
 
johanntagleCommented:
MySQL doesn't accept "Select top 200".  Use "limit 200" at the end (after "order by No desc") instead.
0
 
mankowitzCommented:
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

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now