C B

C B

  • NA
  • 22
  • 21.7k

Linq to SQL does not return INT values from SQL Server

Jun 22 2011 5:48 PM
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";



Answers (8)