Hello
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:
<!-- This is the INT value, no values returned-->
<my:DataGridTextColumn Binding="{Binding Path=Key_Word_int}" IsReadOnly="True"
Header="Major System Number" Width="SizeToHeader" />
<!-- This is the Varchar value, values returned-->
<my:DataGridTextColumn Binding="{Binding Path=Key_Word_Ref}"
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";
Linq to SQL does not return INT values from SQL Server
8 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Suthish NairRank #93 · 22.6K pointsPosted Jun 22, 2011, 10:21 PM EDT
Former memberPosted Jun 22, 2011, 10:58 PM EDT
select p.Key_Word_int).Take(10);
Please try to select only the particular int column and check the result in dbMS object.
C B15 pointsPosted Jun 23, 2011, 12:15 AM EDT
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
Former memberPosted Jun 23, 2011, 3:27 AM EDT
C B15 pointsPosted Jun 23, 2011, 11:34 AM EDT
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
Suthish NairRank #93 · 22.6K pointsPosted Jun 23, 2011, 11:56 AM EDT
C B15 pointsPosted Jun 23, 2011, 12:15 PM EDT
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
C B15 pointsPosted Jun 24, 2011, 7:35 AM EDT
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:
<!-- This is the INT value, no values returned-->
<my:DataGridTextColumn Binding="{Binding Path=Key_Word_Int}" IsReadOnly="True"
Yes, I do feel dumb!
Thanks
C