Thursday, August 28, 2008

How to Insert from ListView with LINQ to SQL

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.

No comments: