Hata_CS1513_} bekleniyor_ [英] Hata_CS1513_} bekleniyor_

查看:58
本文介绍了Hata_CS1513_} bekleniyor_的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你能找到错误吗? :S


使用System;

使用System.Collections.Generic;

使用System.ComponentModel;

使用System.Data;

使用System.Drawing;

使用System.Linq;

使用System.Text;

使用System.Windows.Forms;

使用System.Data.OleDb; //Accesbağlantıdosyaları



namespaceveritabanı_2

{

   公共部门类Form1:表格

    {

        //VeriTabanıDeğişkenleriniTanımlamaBölümü

        OleDbConnection baglanti = new OleDbConnection(" Provider = Microsoft.ACE.OLEDB.12.0; Data Source = pop.accdb");

        OleDbCommand komut = new OleDbCommand();

        OleDbDataAdapter adtr = new OleDbDataAdapter();

        DataSet ds = new DataSet();




        public Form1()

        {

            InitializeComponent();

        }


        // DataGridWievdekayıtlarımuslememebölümü

        void listele()

        {

            baglanti.Open();

            OleDbDataAdapter adtr = new OleDbDataAdapter(" Select * from hepsi",baglanti);

            adtr.Fill(ds," hepsi");

            dataGridView1.DataSource = ds.Tables [" hepsi"];

            adtr.Dispose();

            baglanti.Close();

        }


        // DataGridWievdekayıtlarımuslememebölümü

        private void Form1_Load(object sender,EventArgs e)

        {

            // TODO:Bukodatırı'popDataSet.hepsi'tablosunaveriyükler。 Bunugerektiğişekildetaşıyabilir,veyakaldırabilirsiniz。

            this.hepsiTableAdapter.Fill(this.popDataSet.hepsi);

            listele();

        }


      



        //KayıtEklemeBölümü

        private void button1_Click(object sender,EventArgs e)

        {

 

            {

                komut.Connection = baglanti;

                komut.CommandText =" Insert into hepsi(tckn,isim,soyisim,telefon,adres,ucret,odeme,masraf,avans)Values('" + kayitno.Text +"','" + isim.Text + "','" +
soyisim.Text +"','" + tckn.Text +"','" + adres.Text +"','" + ucret。 Text +"','" + odeme.Text +"','" + masraf.Text +"','" + avans.Text +"')" ;;

                baglanti.Open();

                komut.ExecuteNonQuery();

                komut.Dispose();

                baglanti.Close();

                MessageBox.Show("KayıtTamamlandı!);

                ds.Clear();

                listele();

            }

           否则

            {

                MessageBox.Show("Boşalanlanırakmayınız!");

            }


        }


        //KayıtSilemBölümü

        private void button2_Click(object sender,EventArgs e)

        {

            DialogResult c;

            c = MessageBox.Show("Silmekistediğinizdeneminmisiniz?","Uyarı!",MessageBoxButtons.YesNo,MessageBoxIcon.Question);

            if(c == DialogResult.Yes)

            {

                baglanti.Open();

                komut.Connection = baglanti;

                komut.CommandText ="从hepsi删除kayitno =" + textBox1.Text +"" ;;

                komut.ExecuteNonQuery();

                komut.Dispose();

                baglanti.Close();

                ds.Clear();

                listele();

            }¥b $ b        }


        //KayıtlarıDataGriddenTextboxlaraazdırmabölümü

        private void dataGridView1_CellEnter(object sender,DataGridViewCellEventArgs e)

        {

            kayitno.Text = dataGridView1.CurrentRow.Cells [0] .Value.ToString();

            isim.Text = dataGridView1.CurrentRow.Cells [1] .Value.ToString();

            soyisim.Text = dataGridView1.CurrentRow.Cells [2] .Value.ToString();

            tckn.Text = dataGridView1.CurrentRow.Cells [3] .Value.ToString();

            telefon.Text = dataGridView1.CurrentRow.Cells [4] .Value.ToString();

            adres.Text = dataGridView1.CurrentRow.Cells [5] .Value.ToString();

            ucret.Text = dataGridView1.CurrentRow.Cells [6] .Value.ToString();

            odeme.Text = dataGridView1.CurrentRow.Cells [7] .Value.ToString();

            masraf.Text = dataGridView1.CurrentRow.Cells [8] .Value.ToString();

            avans.Text = dataGridView1.CurrentRow.Cells [9] .Value.ToString();

        }


        //KayıtAramaBölümü

        private void button4_Click(object sender,EventArgs e)

        {

            baglanti = new OleDbConnection(" Provider = Microsoft.ACE.Oledb.12.0; Data Source = pop.accdb");

            adtr = new OleDbDataAdapter(" Select * from hepsi where kayitno like'" + textBox2.Text +"%'",baglanti);

            ds = new DataSet();

            baglanti.Open();

            adtr.Fill(ds," hepsi");

            dataGridView1.DataSource = ds.Tables [" hepsi"];

            baglanti.Close();

        }


        //KayıtGüncellemeBölümü

        private void button3_Click(object sender,EventArgs e)

        {

            komut = new OleDbCommand();

            baglanti.Open();

            komut.Connection = baglanti;

            komut.CommandText =" update hepsi set isim ='" + isim.Text +"',soyisim ='" + soyisim.Text +"',tckn ='" + tckn.Text +"',telefon ='" + telefon.Text
+"',adres ='" + adres.Text +"',ucret ='" + ucret.Text +"',odeme ='" + odeme.Text +"',masraf ='" + masraf.Text +"',avans ='" + avans.Text +"'其中kayitno ="
+ kayitno.Text +"" ;;

            komut.ExecuteNonQuery();

            baglanti.Close();

            ds.Clear();

            listele();

        }¥b $ b    }
}

解决方案

有助于复制您帖子中的完整错误。


如果您要粘贴代码,请使用"插入代码块"。按钮。它使代码更容易阅读。


假设你的标题是
这个
,那么你应该查看它指示的行的错误。唯一的问题是,对于语法错误,缺少括号可能会使括号彼此匹配变得模糊,并使编译器难以找到实际错误
的位置。


我注意到你的button1_click事件中你似乎有大括号和'else'语句但没有'if'语句。也许这也会导致CS1513错误。

 private void button1_Click(object sender,EventArgs e)
{
// ///错过'if'声明? /////
{
komut.Connection = baglanti;
komut.CommandText =" Insert into hepsi(tckn,isim,soyisim,telefon,adres,ucret,odeme,masraf,avans)Values('" + kayitno.Text +"','" + isim.Text +"','" + soyisim.Text +"','" + tckn.Text +"','" + adres.Text +"','" + ucret。 Text +"','" + odeme.Text +"','" + masraf.Text +"','" + avans.Text +"')" ;;
baglanti.Open();
komut.ExecuteNonQuery();
komut.Dispose();
baglanti.Close();
MessageBox.Show("KayıtTamamlandı!");
ds.Clear();
listele();
}
其他
{
MessageBox.Show("Boşalanlanırakmayınız!");
}

}




Could you please find what is wrong. :S

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;
using System.Data.OleDb; //Acces bağlantı dosyaları

namespace veritabanı_2
{
    public partial class Form1 : Form
    {
        //Veri Tabanı Değişkenlerini Tanımlama Bölümü
        OleDbConnection baglanti = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=pop.accdb");
        OleDbCommand komut = new OleDbCommand();
        OleDbDataAdapter adtr = new OleDbDataAdapter();
        DataSet ds = new DataSet();


        public Form1()
        {
            InitializeComponent();
        }

        //DataGridWiev de kayıtları listeleme bölümü
        void listele()
        {
            baglanti.Open();
            OleDbDataAdapter adtr = new OleDbDataAdapter("Select * from hepsi", baglanti);
            adtr.Fill(ds, "hepsi");
            dataGridView1.DataSource = ds.Tables["hepsi"];
            adtr.Dispose();
            baglanti.Close();
        }

        //DataGridWiev de kayıtları listeleme bölümü
        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: Bu kod satırı 'popDataSet.hepsi' tablosuna veri yükler. Bunu gerektiği şekilde taşıyabilir, veya kaldırabilirsiniz.
            this.hepsiTableAdapter.Fill(this.popDataSet.hepsi);
            listele();
        }

      

        //Kayıt Ekleme Bölümü
        private void button1_Click(object sender, EventArgs e)
        {
 
            {
                komut.Connection = baglanti;
                komut.CommandText = "Insert Into hepsi(tckn,isim,soyisim,telefon,adres,ucret,odeme,masraf,avans) Values ('" + kayitno.Text + "','" + isim.Text + "','" + soyisim.Text + "','" + tckn.Text + "','" + adres.Text + "','" + ucret.Text + "','" + odeme.Text + "','" + masraf.Text + "','" + avans.Text + "')";
                baglanti.Open();
                komut.ExecuteNonQuery();
                komut.Dispose();
                baglanti.Close();
                MessageBox.Show("Kayıt Tamamlandı!");
                ds.Clear();
                listele();
            }
            else
            {
                MessageBox.Show("Boş alan bırakmayınız!");
            }

        }

        //Kayıt Silem Bölümü
        private void button2_Click(object sender, EventArgs e)
        {
            DialogResult c;
            c = MessageBox.Show("Silmek istediğinizden emin misiniz?","Uyarı!",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
            if (c == DialogResult.Yes)
            {
                baglanti.Open();
                komut.Connection = baglanti;
                komut.CommandText = "Delete from hepsi where kayitno=" + textBox1.Text + "";
                komut.ExecuteNonQuery();
                komut.Dispose();
                baglanti.Close();
                ds.Clear();
                listele();
            }
        }

        //Kayıtları DataGridden Textboxlara yazdırma bölümü
        private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)
        {
            kayitno.Text = dataGridView1.CurrentRow.Cells[0].Value.ToString();
            isim.Text = dataGridView1.CurrentRow.Cells[1].Value.ToString();
            soyisim.Text = dataGridView1.CurrentRow.Cells[2].Value.ToString();
            tckn.Text = dataGridView1.CurrentRow.Cells[3].Value.ToString();
            telefon.Text = dataGridView1.CurrentRow.Cells[4].Value.ToString();
            adres.Text = dataGridView1.CurrentRow.Cells[5].Value.ToString();
            ucret.Text = dataGridView1.CurrentRow.Cells[6].Value.ToString();
            odeme.Text = dataGridView1.CurrentRow.Cells[7].Value.ToString();
            masraf.Text = dataGridView1.CurrentRow.Cells[8].Value.ToString();
            avans.Text = dataGridView1.CurrentRow.Cells[9].Value.ToString();
        }

        //Kayıt Arama Bölümü
        private void button4_Click(object sender, EventArgs e)
        {
            baglanti = new OleDbConnection("Provider=Microsoft.ACE.Oledb.12.0;Data Source=pop.accdb");
            adtr = new OleDbDataAdapter("SElect *from hepsi where kayitno like '" + textBox2.Text + "%'", baglanti);
            ds = new DataSet();
            baglanti.Open();
            adtr.Fill(ds, "hepsi");
            dataGridView1.DataSource = ds.Tables["hepsi"];
            baglanti.Close();
        }

        //Kayıt Güncelleme Bölümü
        private void button3_Click(object sender, EventArgs e)
        {
            komut = new OleDbCommand();
            baglanti.Open();
            komut.Connection = baglanti;
            komut.CommandText = "update hepsi set isim='" + isim.Text + "', soyisim='" + soyisim.Text + "', tckn='" + tckn.Text + "', telefon='" + telefon.Text + "', adres='" + adres.Text + "', ucret='" + ucret.Text + "', odeme='" + odeme.Text + "', masraf='" + masraf.Text + "', avans='" + avans.Text + "' where kayitno=" + kayitno.Text + "";
            komut.ExecuteNonQuery();
            baglanti.Close();
            ds.Clear();
            listele();
        }
    }
}

解决方案

It helps to copy out the full error in your posts.

And if you are pasting code, use the "insert code block" button. It makes the code much easier to read.

Assuming, by your title, you are talking about this, then you should look in the error for the line it is indicating. The only issue is that for syntax errors, a missing bracket can make it ambiguous which brackets match each other and make it difficult for the compiler to spot where the real error is.

I noticed in your button1_click event you seem to have curly brackets and an 'else' statement but with no 'if' statement. Maybe this can cause the CS1513 error as well.

 private void button1_Click(object sender, EventArgs e)
 {
        ///// MISSING 'if' STATEMENT? /////
        {
            komut.Connection = baglanti;
            komut.CommandText = "Insert Into hepsi(tckn,isim,soyisim,telefon,adres,ucret,odeme,masraf,avans) Values ('" + kayitno.Text + "','" + isim.Text + "','" + soyisim.Text + "','" + tckn.Text + "','" + adres.Text + "','" + ucret.Text + "','" + odeme.Text + "','" + masraf.Text + "','" + avans.Text + "')";
            baglanti.Open();
            komut.ExecuteNonQuery();
            komut.Dispose();
            baglanti.Close();
            MessageBox.Show("Kayıt Tamamlandı!");
            ds.Clear();
            listele();
        }
        else
        {
            MessageBox.Show("Boş alan bırakmayınız!");
        }

 }



这篇关于Hata_CS1513_} bekleniyor_的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆