我需要创建一个如下所示的应用程序.

编程入门 行业动态 更新时间:2024-10-27 11:17:43
本文介绍了我需要创建一个如下所示的应用程序.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要创建一个如下所示的应用程序.... 应该有一些文本框.将数据输入文本框后,我需要单击添加按钮.那么数据应该包含在gridview以及我的数据库中...我该怎么做?

I need to create an application like below.... there should be some text box.after giving the data into the text box i need to click the add button. then the data should be included in the gridview as well as in my database...how should i do that?

推荐答案

您是否尝试过 google [ ^ ] 将此代码放在您的button_click上,以在datagridview中添加行: Have you tried google[^] Right this code on your button_click to add rows in datagridview: int row = dgvSubjects.Rows.Add(); dgvSubjects.Rows[row].Cells["ID"].Value = "0"; //this is just for your reference, as per your columns in grid you can update column names. dgvSubjects.Rows[row].Cells["SubjectName"].Value = txtSubjectName.Text; dgvSubjects.Rows[row].Cells["SubjectDetails"].Value = txtSubjectDetails.Text; dgvSubjects.Rows[row].Cells["SubjectCategory"].Value = cmbSubjectCategoryGID.Text; dgvSubjects.Rows[row].Cells["SubjectCategoryGID"].Value = cmbSubjectCategoryGID.SelectedValue; dgvSubjects.Rows[row].Cells["DueDate"].Value = dtpDueDate.Value.ToShortDateString();

并将您的数据保存在数据库中,以供参考,您可以 google [ ^ ]再来一次

And save your data in database, for reference you can google[^] it again

那有什么大不了的呢. 现在使用插入查询ob按钮单击: So what is the Big deal. Now Use insert query ob button click: SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["Con"].ToString()); cn.Open(); // Insert Query According to Your Form string qry = "insert into Table_Name([Your_Column1],[Your_Column2])VALUES(@Your_Column1,@Your_Column2)"; SqlCommand cmd = new SqlCommand(qry,cn); cmd.Parameters.Add("@Your_Column1", SqlDbType.YourDataType).Value = TextBOX1.Text; cmd.Parameters.Add("@Your_Column2",SqlDbType.VarChar).Value = DropDownList1.SelectedValue; cmd.ExecuteNonQuery(); cn.close();

更多推荐

我需要创建一个如下所示的应用程序.

本文发布于:2023-11-16 02:41:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1600271.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:所示   创建一个   应用程序

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!