テキストボックスからデータを挿入して更新したい。
データがデータベースに更新されないのはなぜですか? (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)