I cannot get INT values to appear in my WPF datagrid when I use Linq to SQL. Varchar values appear, from the same table, with out issue.
Where am I going wrong? Do I have to add some code to convert the INT to system.int32.
Thanks for your time.
Example of WPF databinding:
Header="Major System Number" Width="SizeToHeader" />
Header="Major System Reference" Width="SizeToHeader" />
Example of Ling to SQL:
L2SMSDataContext cd = new L2SMSDataContext();
var dbMS = (from p in cd.Key_Words
select p).Take(10);
MSGrid.ItemsSource = dbMS;
MSInfo.Content = "MS Data Loaded";

C BPosted Jun 24, 2011, 11:35 AM
I have found the problem and it was a very simple one. The word "int" should be "Int" in the XAML code, since the name of the table in SQL Server is called "Key_Word_Int".
A simple mistake which I will take note of for future reference.
The code should read like this:
Yes, I do feel dumb!
Thanks
C
C BPosted Jun 23, 2011, 4:15 PM
Good spot but no cigar. I took out the extra space and still got nothing. I think it has to be something with the table in SQL Server Express. I going to recreate the Database and see what happens.
I will class this post as closed.
Thanks
C
Suthish NairPosted Jun 23, 2011, 3:56 PM
C BPosted Jun 23, 2011, 3:34 PM
It must be something wrong with the table in SQL server express. I created another Datagrid with WPF using Northwind. From the Orders table I choose EmployeeID. EmployeeID has the exact configuration as Key_Word_Int in SQL Server express.
EmployeeID returns INT values without any issues. Bashing my head against a brick wall is very appealing at this moment.
Thanks for your time, I am going to start from scratch again.
Cheers
C
Posted Jun 23, 2011, 7:27 AM
C BPosted Jun 23, 2011, 4:15 AM
Suthish: Yes the dbMS contains that record. I created a table with 2 columns i.e. Key_Word_int, Key_Word_Ref.
Murali: I will try selecting the particular int column. I will do this when I get back from work.
I am using C# 2008 Express (would that make any difference?).
Thanks
C
Posted Jun 23, 2011, 2:58 AM
select p.Key_Word_int).Take(10);
Please try to select only the particular int column and check the result in dbMS object.
Suthish NairPosted Jun 23, 2011, 2:21 AM