求助。vb.net如何更新MYSQL数据库里某个表的值?
时间:2011-12-09
来源:互联网
我已经学会查询并显示MYSQL数据库里的信息了。可是我研究了好久。都没学会如何更新数据库表的值。我的查询是这样的。
connStr = String.Format("Server=" & Server & ";Port=" & Port & ";Database=" & db & ";Uid=" & User & ";Pwd=" & Pass & "; pooling=false;")
Dim sql As String = "select password,salt,uid,username from pre_ucenter_members where username='" & username & "'"
Dim ds As New System.Data.DataTable
Dim cmd As New MySqlDataAdapter(sql, connStr)
cmd.Fill(ds)
If ds.Rows.Count > 0 Then
.............
MsgBox("用户登陆成功!", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "用户登陆成功!")
Else
MsgBox("用户密码错误!", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "用户密码错误!")
password1.Focus()
ds.Dispose()
End If
...............
End If
我的更新语句是这样的。
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim connStr As String
connStr = String.Format("Server=" & Server & ";Port=" & Port & ";Database=" & db & ";Uid=" & User & ";Pwd=" & Pass & "; pooling=false;")
Try
Dim sqlstr As String
'定义一个修改语句
sqlstr = "update count set ext6='" & 101 & "' where uid=1"
'设置Command对象
Dim Comm As New MySqlCommand(sqlstr)
Comm.ExecuteNonQuery()
'关闭数据库连接
Comm.Connection.Close()
MsgBox("用户修改成功。", MsgBoxStyle.OkOnly + _
MsgBoxStyle.Exclamation, "用户修改成功")
Catch ex As Exception
MsgBox("添加失败。", MsgBoxStyle.OkOnly + MsgBoxStyle.Exclamation, "添加失败")
End Try
End Sub
提示修改用户失败。。。。不知道怎么写才是正确的更新语句。。。。。
提示修改用户失败。。。。不知道怎么写才是正确的更新语句。。。。。
提示修改用户失败。。。。不知道怎么写才是正确的更新语句。。。。。
提示修改用户失败。。。。不知道怎么写才是正确的更新语句。。。。。
connStr = String.Format("Server=" & Server & ";Port=" & Port & ";Database=" & db & ";Uid=" & User & ";Pwd=" & Pass & "; pooling=false;")
Dim sql As String = "select password,salt,uid,username from pre_ucenter_members where username='" & username & "'"
Dim ds As New System.Data.DataTable
Dim cmd As New MySqlDataAdapter(sql, connStr)
cmd.Fill(ds)
If ds.Rows.Count > 0 Then
.............
MsgBox("用户登陆成功!", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "用户登陆成功!")
Else
MsgBox("用户密码错误!", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "用户密码错误!")
password1.Focus()
ds.Dispose()
End If
...............
End If
我的更新语句是这样的。
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim connStr As String
connStr = String.Format("Server=" & Server & ";Port=" & Port & ";Database=" & db & ";Uid=" & User & ";Pwd=" & Pass & "; pooling=false;")
Try
Dim sqlstr As String
'定义一个修改语句
sqlstr = "update count set ext6='" & 101 & "' where uid=1"
'设置Command对象
Dim Comm As New MySqlCommand(sqlstr)
Comm.ExecuteNonQuery()
'关闭数据库连接
Comm.Connection.Close()
MsgBox("用户修改成功。", MsgBoxStyle.OkOnly + _
MsgBoxStyle.Exclamation, "用户修改成功")
Catch ex As Exception
MsgBox("添加失败。", MsgBoxStyle.OkOnly + MsgBoxStyle.Exclamation, "添加失败")
End Try
End Sub
提示修改用户失败。。。。不知道怎么写才是正确的更新语句。。。。。
提示修改用户失败。。。。不知道怎么写才是正确的更新语句。。。。。
提示修改用户失败。。。。不知道怎么写才是正确的更新语句。。。。。
提示修改用户失败。。。。不知道怎么写才是正确的更新语句。。。。。
作者: hsx49949046 发布时间: 2011-12-09
sqlstr = "update count set ext6='" & 101 & "' where uid=1"
101是啥?变量吗?
sqlstr = "update count set ext6='101' where uid=1"
101是啥?变量吗?
sqlstr = "update count set ext6='101' where uid=1"
作者: eaqpi 发布时间: 2011-12-09
dim ext6 as string ="101"
sqlstr = "update count set ext6='" & ext6 & "' where uid=1"
------------------
dim ext6 as integer =101
sqlstr = "update count set ext6=" & ext6 & " where uid=1"
sqlstr = "update count set ext6='" & ext6 & "' where uid=1"
------------------
dim ext6 as integer =101
sqlstr = "update count set ext6=" & ext6 & " where uid=1"
作者: eaqpi 发布时间: 2011-12-09
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28