本文介绍了如何在msaccess数据库中保存复选框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Datagridview中进行如下设计;



天会议1会话2



1复选框检查包装盒

2复选框复选框



i想在数据库中保存以上记录。



我怎么能用csharp?



将上面的复选框值插入msaccess数据库。



请帮帮我。



问候,

Narasiman P.

解决方案


  string  connStr =    Provider = Microsoft.ACE.OLEDB.12.0; Data Source = application.accdb; Persist Security Info = True; 
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = connStr;

OleDbDataAdapter adapter = new OleDbDataAdapter();
adapter.InsertCommand = new OleDbCommand();
foreach (DataGridViewRow dgvr in datagrid1.Rows)
{
// 获取基础数据行
DataRow dr =((DataRowView)dgvr.DataBoundItem)。行;

// 我假设你的tabel包含三列Id int,Session1 boolean,Session2 boolean

adapter.InsertCommand.CommandText = INSERT INTO表(Id,Session1) ,Session2) + VALUES( + dr [ ] + +(dr [ session 1])? 1 0 + ',' +(dr [ session 2]) ? 1 0 + ');;
conn.Open();
adapter.InsertCommand.Connection = conn;
adapter.InsertCommand.ExecuteNonQuery();
}



Design as follows in Datagridview ;

Days session 1 session 2

1 check box check box
2 check box check box

i want to save the above record in the database .

for that how can i do using csharp?

to insert the above checkbox values into the msaccess database.

Please help me.

Regards,
Narasiman P.

解决方案




这篇关于如何在msaccess数据库中保存复选框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 07:33
查看更多