我希望从文本框中插入和更新数据。
为什么我的数据没有更新到数据库中?(Microsoft SQL Server Management Studio)任何人请帮助我。欣赏!
//connection
//update
If dt.Rows.Count > 0 Then
If dt.Rows.Count > 0 Then
sql = "Update adm SET qty = '" & txtqty.Text & "' Where xxx = '" & Trim(Session("xxx")) & "' "
cmd = New SqlCommand(sql, conn)
'conn.open()
cmd.ExecuteNonQuery()
txtqty.Text = ""
Else
// do insert
crow = ds.tables("adm").newrow()
crow("xxx") = Session("xxxx")
crow("xxx") = Session("xxx")
crow("xxx") = xxxxx
crow("xxx") = xxxxx
crow("xxxxx") = xxxxx
crow("xxxx") = xxxxx
crow("xxxxx") = xxxxx
crow("xxxx") = xxxxx
crow("xxxx") = xxxxx
crow("qty") = trim(txtqty.text)
ds.tables("adm").rows.add(crow)
da.update(ds, "adm")
lbl.Text = "<strong>Data saved! </font></strong>"
conn.close()
End If
这是连接
sql = "SELECT * FROM adm "
conn = New SqlConnection(ConnStr)
cmd = New SqlCommand(sql, conn)
conn.open()
da = New SqlDataAdapter(cmd)
cb = New SqlCommandBuilder(da)
ds = New DataSet
da.fill(ds, "adm")
dt = ds.Tables(0)