Hello guys.
I have code here from my previous project.
This code show on how to save in database using linq to sql from listview.
First:
Create 1 listview and 1 button.
Second:
Create your connectionstring and *.dbml file.
Then copy this code to your project.
private void button2_Click(object sender, EventArgs e)
{
DataClasses1DataContext DCDC = new DataClasses1DataContext();
for (int i = 0; i <= listView1.Items.Count - 1; i++)
{
var q =
from a in Convert.ToString(DCDC.Table11(listView1.Items[i].SubItems[0].Text))
select a;
}
}
Hope this one can help.
Thursday, August 28, 2008
Thursday, August 7, 2008
How to Load DataGridView in LINQ to SQL
First Step. Make sure you have sql server 2000/05/08
Second Step. If you have Database at your sql server, Add DataClasses1 in your project.
Third Step. Drag the table from your Database to your DataClasses Window.
Fourth Step. Add DataGridView to your Form and Button.
Copy this code to your button.
private void button1_Click(object sender, EventArgs e)
{
DataClasses1DataContext dc = new DataClasses1DataContext();
var q =
from a in dc.GetTable()
select a;
Grid1.DataSource = q;
}
Second Step. If you have Database at your sql server, Add DataClasses1 in your project.
Third Step. Drag the table from your Database to your DataClasses Window.
Fourth Step. Add DataGridView to your Form and Button.
Copy this code to your button.
private void button1_Click(object sender, EventArgs e)
{
DataClasses1DataContext dc = new DataClasses1DataContext();
var q =
from a in dc.GetTable
select a;
Grid1.DataSource = q;
}
Subscribe to:
Posts (Atom)