Something wrong on my very first LINQ to SQL c # code
Posted
by user334813
on Stack Overflow
See other posts from Stack Overflow
or by user334813
Published on 2010-05-06T20:36:14Z
Indexed on
2010/05/06
20:48 UTC
Read the original article
Hit count: 151
c#
|linq-to-sql
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Advanced_LinQ_Query
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private DataClasses1DataContext database = new DataClasses1DataContext();
private void Form1_Load(object sender, EventArgs e)
{
database.Log= Console.Out;
comboBox.SelectedIndex=0;
}
private void titleBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
Validate();
titleBindingSource.EndEdit();
database.SubmitChanges();
comboBox.SelectedIndex=0;
}
private void comboBox_SelectedIndexChanged(object sender, EventArgs e)
{
switch (comboBox.SelectedIndex)
{
case 0:
titleBindingSource.DataSource =
from Title in database.Titles
orderby Title.BookTitle
select Title;
break;
case 1:
titleBindingSource.DataSource =
from Title in database.Titles
where Title.Copyright == "2008"
orderby Title.BookTitle
select Title;
break;
case 2:
titleBindingSource.DataSource =
from Title in database.Titles
where Title.BookTitle.EndsWith("How to Program")
orderby Title.BookTitle
select Title;
break;
}
titleBindingSource.MoveFirst();
}
}
}
no connection seems to built after debugging between Title table in my database (book.mdf) and titleBindingSource! Where is the problem?
© Stack Overflow or respective owner