Thread: Table not showing data

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    113

    Table not showing data

    I just want user to select something from combobox and then whole row corresponding to that value should get displayed in datagrid. I am getting table but not getting any data in it.

    Code:
     cmd = New OleDbCommand("select * from titles where title_id=('@a') ", con);
    cmd.Parameters.Add("@a", OleDbType.VarChar);
    cmd.Parameters("@a").Value=ComboBox1.SelectedItem();
    
    da.SelectCommand = cmd;
    
    da.Fill(ds);
    DataGrid1.DataSource = ds;
    Probably error is in first line.Because if I change command to select * from titles and comment out second and third line,it shows whole table.
    Please help

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    113
    Wow! There is no reply.Ok I have found it myself
    Code:
    cmd = New OleDbCommand("select * from titles where title_id=('@a') ", con);
    The real culprit is single quotes in '@a'.Instead of parameterised query it now simply searches for @a record

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Group Project Help/Volunteer
    By DarkDot in forum C++ Programming
    Replies: 3
    Last Post: 04-24-2007, 11:36 PM
  2. Reading a file with Courier New characters
    By Noam in forum C Programming
    Replies: 3
    Last Post: 07-07-2006, 09:29 AM
  3. inputting words from a file
    By kashifk in forum C++ Programming
    Replies: 5
    Last Post: 10-24-2003, 07:18 AM
  4. rehash help
    By kashifk in forum C++ Programming
    Replies: 1
    Last Post: 10-22-2003, 06:51 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM