Şimdi Ara

C# ile sql'den datagrid'e veri çekme

Daha Fazla
Bu Konudaki Kullanıcılar: Daha Az
2 Misafir - 2 Masaüstü
5 sn
2
Cevap
0
Favori
298
Tıklama
Daha Fazla
İstatistik
  • Konu İstatistikleri Yükleniyor
0 oy
Öne Çıkar
Sayfa: 1
Giriş
Mesaj
  • Merhaba,

    Maaş hesaplamaları için içerisinde prim sistemi bulunan bir program yazıyorum. Aşağıda ki kodlamayı yazdım ancak veri sql'den datagrid'e veri çekemiyorum.

     
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.Data.SqlClient;
    namespace WindowsFormsApplication1

    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }
    void griddoldur()
    {

    SqlConnection baglanti = new SqlConnection("Data Source = Superonline; database = bilpe ; integrated security = true");
    SqlDataAdapter veri = new SqlDataAdapter(" select tc, ad, soyad from kisi_bilgileri ", baglanti);
    DataSet data = new DataSet();
    baglanti.Open();
    veri.Fill(data, "kisi_bilgileri");
    dataGridView1.DataSource = data.Tables["kisi_bilgileri"];
    baglanti.Close();
    }
    private void Form1_Load(object sender, EventArgs e)
    {
    griddoldur();
    }

    private void button1_Click(object sender, EventArgs e)
    {
    double satis = Convert.ToDouble(txtsatis.Text);

    string gün =txtgün.Text;
    double hesap;
    if (satis >= 0 && satis <= 259)
    {
    if (gün == "")
    {
    gün =" 0";
    }
    hesap = 1200 -( Convert.ToDouble(gün)*40);
    txtmaas.Text = hesap.ToString();
    }
    else if (satis >= 260 && satis <= 299)
    {
    if (gün == "")
    {
    gün = " 0";
    }
    double satisson = satis - 260;
    double euro = (Convert.ToDouble(txteuro.Text)*satisson)*2;
    hesap = (1500 - Convert.ToDouble(gün) * 50)+200+euro;
    txtmaas.Text = hesap.ToString();
    }
    else if (satis >= 300&& satis <= 399)
    {
    if (gün == "")
    {
    gün = " 0";
    }
    double satisson = satis - 260;
    double euro = (Convert.ToDouble(txteuro.Text) * satisson) * 2;
    hesap = (1500 - Convert.ToDouble(gün) * 50) + 200 + euro+240;
    txtmaas.Text = hesap.ToString();
    }
    else if (satis >= 400 && satis <= 499)
    {
    if (gün == "")
    {
    gün = " 0";
    }
    double satisson = satis - 260;
    double euro = (Convert.ToDouble(txteuro.Text) * satisson) * 2;
    hesap = (1500 - Convert.ToDouble(gün) * 50) + 200 + euro+840;
    txtmaas.Text = hesap.ToString();
    }
    else if (satis >= 500 && satis <= 599)
    {
    if (gün == "")
    {
    gün = " 0";
    }
    double satisson = satis - 260;
    double euro = (Convert.ToDouble(txteuro.Text) * satisson) * 2;
    hesap = (1500 - Convert.ToDouble(gün) * 50) + 200 + euro+1440;
    txtmaas.Text = hesap.ToString();
    }
    else if (satis >= 600 && satis <= 699)
    {
    if (gün == "")
    {
    gün = " 0";
    }
    double satisson = satis - 260;
    double euro = (Convert.ToDouble(txteuro.Text) * satisson) * 2;
    hesap = (1500 - Convert.ToDouble(gün) * 50) + 200 + euro + 2040;
    txtmaas.Text = hesap.ToString();
    }
    else
    {
    MessageBox.Show("Yanlış Skala Girdiniz!");
    }
    }
    }
    }








  • Konuyu kaldırabilirsiniz, sorun sql server'den kaynaklanıyormuş..
  • 
Sayfa: 1
- x
Bildirim
mesajınız kopyalandı (ctrl+v) yapıştırmak istediğiniz yere yapıştırabilirsiniz.