用checkboxlist选择后存如数据库

用checkboxlist选择后存如数据库,第1张

protected

void

btnd_Click(object

sender,

EventArgs

e)

{

for

(int

i

=

0

i

<

CheckBoxList1.Items.Count

i++)

{

if

(CheckBoxList1.Items[i].Selected

==

true)

{

//存数据库

string

courename

=

this.CheckBoxList1.Items[i].Value.ToString()

string

sqlstr

=

"Data

Source=.Initial

Catalog=JobWanted

ApartmentIntegrated

Security=true"

string

sql

=

"insert

into

test

(dfdf)values('"

+

courename

+

"')"

SqlConnection

con

=

new

SqlConnection(sqlstr)

con.Open()

SqlCommand

cmd

=

new

SqlCommand(sql,

con)

cmd.ExecuteNonQuery()

//读数据库

string

sql2

=

"select

*

from

test"

SqlCommand

cmd1

=

new

SqlCommand(sql2,

con)

SqlDataAdapter

adapter

=

new

SqlDataAdapter(cmd1)

DataSet

ds

=

new

DataSet()

DataTable

dt

=

new

DataTable()

adapter.Fill(ds)

dt

=

ds.Tables[0]

this.TextBox1.Text

=

dt.Rows[0][0].ToString()

this.TextBox2.Text

=

dt.Rows[0][1].ToString()

con.Close()

}

else

{

Response.Write("<script>alert('您还未选课!')</script>")

}

}

}

这是大致思想,一些细节你自己来弄了。。。数据库名

表名

列名改下

你的做法

展示已选课的课程的时候应该用数据控件的,直接把dataset绑定到gridview上就OK了。。。

job security: 工作保障,职业安全感

例句与用法:

1.The workers agreed to forgo a pay increase for the sake of greater job security.

工人们为了工作更保险, 同意放弃增加工资的要求.

portfolio worker 文件夹上班族

汉迪生造了“文件夹上班族”(portfolio worker)这个词送给自由职业者;

portfolio:n. 文件夹,证券投资组合

例句与用法:

1. My stockbroker manages my portfolio for me.

我的证券经纪人替我管理投资组合.

2. She resigned her portfolio.

她辞去了大臣职务.

3. A mathematical measure of the sensitivity of rates of return on a portfolio or a given stock compared with rates of return on the market as a whole. A high degree of such sensitivity indicates moderate or high price volatility.

证券的β因素一种数学手段,对某有价证券或某种给定股票的回报率与整个市场回报率相比的敏感性进行测量。这种高程度敏感性表明其价位处于中度或高度易变状态

4. He went through drawer after drawer and eventually searched out a dusty portfolio.

他一个一个抽屉查找,后来终于找出了一份沾满灰尘的文件夹。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/9417025.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-28
下一篇 2023-04-28

发表评论

登录后才能评论

评论列表(0条)

保存