Table not showing data

This is a discussion on Table not showing data within the C# Programming forums, part of the General Programming Boards category; I just want user to select something from combobox and then whole row corresponding to that value should get displayed ...

  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-25-2007, 12:36 AM
  2. Reading a file with Courier New characters
    By Noam in forum C Programming
    Replies: 3
    Last Post: 07-07-2006, 10:29 AM
  3. inputting words from a file
    By kashifk in forum C++ Programming
    Replies: 5
    Last Post: 10-24-2003, 08:18 AM
  4. rehash help
    By kashifk in forum C++ Programming
    Replies: 1
    Last Post: 10-22-2003, 07:51 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 07:49 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21