Rss & SiteMap
Foxtable(狐表) http://www.foxtable.com
控件值都能正确地写到相应的字段中,就是有几个控件就会增加几行,估计是循环语句的问题,可又不知如何弄了哈
呵呵,你的scm.ExecuteNonQuery就在循环语句之中,每循环一次就插入一行,你应该将其挪到循环语句之外。 Dim Multi As String = "姓名,性别,年龄" Dim Values() as String Values = Multi.split(",") dim y as String = "" dim s as String = "" For Index As Integer = 0 To Values.Length - 1 if e.Form.Controls(Values(Index)).Value = nothing MessageBox.Show("对不起,您输入的信息不全,请录入<" & Values(Index) & ">后再继续!", "提示") e.Form.Controls(Values(Index)).Select() Return end if y = y & "," & Values(Index) s = s & ",'" & e.Form.Controls(Values(Index)).value & "'" Next Dim scm as New SQLCommand scm.ConnectionName = "y" scm.CommandText = "Insert Into 民兵 " & "(" & y.Trim(",") & ")" & "" & "" & "Values(" & s.Trim(",") & ")" scm.ExecuteNonQuery 大概就是这样,你自己调试一下吧 |