listbox’taki tüm bilgileri veri tabanına ekleme C#

listbox’taki tüm bilgileri veri tabanına ekleme C#

Daha fazla bilgi için : www.gorselprogramlama.com

[code language=”csharp”]

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Data.OleDb;

using System.Linq;

using System.Text;

using System.Windows.Forms;

namespace WindowsFormsApplication7

{

public partial class Form1 : Form

{

OleDbConnection bag = new OleDbConnection();

OleDbCommand sorgu= new OleDbCommand();

public Form1()

{//Daha fazla bilgi için : www.gorselprogramlama.com

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

bag.ConnectionString = ("provider=Microsoft.Jet.Oledb.4.0;Data Source=veri.mdb");

bag.Open();

sorgu.Connection = bag;

for (int i=0;i<listBox1.Items.Count;i++ )

{

sorgu.CommandText="insert into kisib(ad) values (‘"+listBox1.Items[i].ToString()+"’)";

sorgu.ExecuteNonQuery();

}

bag.Close();

MessageBox.Show("Kayıt işlemi tamamlandı");

}

}

}

[/code]

Daha fazla bilgi için : www.gorselprogramlama.com

Yorumlar 7

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir