简体   繁体   English

如何在Windows窗体应用程序的表中添加记录

[英]How to add record in table in windows form application

i am working on some data entry program in windows form, i write the following code on button click event to add records in table but records doesn't add it gives me an error of execute non query 我正在使用Windows窗体中的某些数据输入程序,我在按钮单击事件上编写以下代码以在表中添加记录,但记录未添加它给我执行非查询错误

private void button2_Click(object sender, EventArgs e)        
{             
    SqlConnection con = new SqlConnection("Data Source=JASMEETSINGH-PC;Initial Catalog=Desnet;Integrated Security=True"); 
    con.Open();   
    SqlCommand cmd = new SqlCommand("Insert into BillEntry values('" + textBox1.Text + "', '" + textBox2.Text + "', '" + textBox3.Text + "', '" + dateTimePicker1.DataBindings + "', '" + textBox4.Text + "', '" + dateTimePicker2.DataBindings + "', '" + radioButton1.DataBindings + "', '" + radioButton2.DataBindings                 + "', '" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text + "','" + textBox9.Text + "','" + textBox10.Text + "')", con);     
    int i = cmd.ExecuteNonQuery();  
    if (i > 0)           
    {                 
        label15.Text = "Record Added Successfully";            
    } 
}

data type used:- varchar(10) varchar(100) varchar(20) date varchar(25) date char(3) float float float varchar(20) varchar(50) float 使用的数据类型:-varchar(10)varchar(100)varchar(20)date varchar(25)date char(3)float float varchar(20)varchar(50)float

检查单引号和双引号可能是问题所在,因为我们使用了“”“',但是对于int

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何为Windows窗体应用程序添加迷你图? - how to add sparkline to windows form application? 我将如何获取最后一个最大记录ID,增量ID,然后将记录添加到表C#应用程序中 - How would I Get last max record ID,Increment ID and then add record to table C# application 如何将System.Web引用添加到Windows窗体应用程序 - How Add System.Web Reference To A Windows Form Application 如何在Windows窗体应用程序中的复选框前添加图像 - How to add an image before a checkbox in Windows form application 如何在Windows窗体应用程序的DataGridView行中动态添加控制? - How to add Contols Dynamically in DataGridView Row in Windows Form Application? 如何在网格视图中的行上添加onclick事件(Windows窗体应用程序) - How to add onclick event on a row in grid view (windows form application) 如何在 c# windows 表单应用程序中将图标添加到上下文菜单 - how to add icon to context menu in c# windows form application 如何在Windows窗体应用程序中从数据库中添加值 - How to add values together from a database in windows form application 如何在第三方 windows 表单应用程序上添加带有事件的按钮? - How to add button with events on third party windows form application? 在 Windows 应用程序表单中记录桌面(非表单)上的鼠标移动 - record mouse movements on desktop (not form) in windows application form
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM