关于记录行保存的问题(asp.net & vb.net),热心的英俊的潇洒的才华横溢的兄弟们请进!
代码:
定义一个过程,将数据库中符合指定条件的记录的name改为在文本框输入的内容。
Sub update()
Dim conn As New SqlConnection(ConfigurationSettings.AppSettings( "cns "))
Dim cmdstr As String
Dim cmd As SqlCommand
Dim adp As SqlDataAdapter
Dim ds As DataSet
cmdstr = "select * from newsarticle where id= " & ddl.SelectedValue
cmd = New SqlCommand(cmdstr, conn)
adp = New SqlDataAdapter
adp.SelectCommand = cmd
ds = New DataSet
adp.Fill(ds, "na ")
Dim tb As New DataTable
Dim tr As DataRow
tb=ds.tables( "na ")
For Each tr In tb.Rows
tr( "name ") =t1.text
Next
End Sub
尝试以下几个方法都不能保存记录,
tb.AcceptChanges()
adp.AcceptChangesDuringFill
adp.AcceptChangesDuringUpdate
adp.Update(ds)
请问如何将修改后的记录保存在数据库中?请高手指点。
------解决方案--------------------我满足你以上条件,但是VB不熟........
------解决方案--------------------ASP.NET不熟..........
------解决方案--------------------VB看的眼花
------解决方案--------------------你这个也搞的太麻烦了吧,给你个简单的例子:
Sub update()
Dim conn As New SqlConnection(ConfigurationSettings.AppSettings( "cns "))
Dim cmdstr As String
cmdstr= "update newsarticle set name= ' "+t1.text+ " ' where name= ' "+ddl.SelectedValue+ " ' "
Dim cmd As SqlCommand=New SqlCommand(cmdstr, conn)
cmd.executeNonQuery()
conn.close()
end sub
------解决方案--------------------我学 C# 的
------解决方案--------------------同时满足以上条件
------解决方案--------------------