【发布时间】:2017-09-15 21:53:38
【问题描述】:
我是 C# 程序员的新手,我在学习 youtube 上的教程时编写了一个代码,我想通过添加功能来改进它。
但是,当我运行程序时,我不断收到错误:
“System.Data.OleDb.OleDbException”类型的未处理异常 发生在 System.Data.dll
内部异常是:
INSERT INTO 语句中的语法错误
我检查了一下,代码对我来说似乎是正确的。
我仔细检查了 Access 文件中的所有列,所有列都拼写正确。
这是我的代码:
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.OleDb;
namespace Biletotomasyon
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
OleDbConnection baglanti=new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:/Users/msi-nb/Documents/Visual Studio 2013/Projects/Biletotomasyon/YOLCU.accdb");
private void radioButton3_CheckedChanged(object sender, EventArgs e)
{
}
private void label7_Click(object sender, EventArgs e)
{
}
private void comboBox7_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void button56_Click(object sender, EventArgs e)
{
baglanti.Open();
OleDbCommand komut=new OleDbCommand ("INSERT INTO YOLCU (SEFER SAYISI,GÜZERGAH,VARİŞ YERİ,TARİH,SAAT,PERON,AD SOYAD,KOLTUKNO,TAM BİLET ÜCRETİ,TC,IB SAYISI,TOPLAM ÜCRET,CİNSİYET,BİLET CİNSİ) values ('"+comboBox7.Text.ToString()+"','"+comboBox6.Text.ToString()+"','"+comboBox1.Text.ToString()+"','"+ dateTimePicker1.Text.ToString()+"','"+comboBox5.Text.ToString()+"','"+comboBox2.Text.ToString()+"','"+textBox1.Text.ToString()+"','"+comboBox4.Text.ToString()+"','"+comboBox3.Text.ToString()+"','"+textBox2.Text.ToString()+"','"+textBox3.Text.ToString()+"',,'"+textBox4.Text.ToString()+"','"+radioButton1.Text.ToString()+"','"+radioButton3.Text.ToString()+"')",baglanti);
komut.ExecuteNonQuery();
baglanti.Close();
}
}
}
有什么问题?我该如何解决?
【问题讨论】:
-
两个逗号相邻。
,,删除其中一个。
标签: c#