更新stetment问题 [英] update stetment problem

查看:192
本文介绍了更新stetment问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果conn.State = False那么
conn.Open()
Com.Connection = conn
Com.CommandType = CommandType.Text
Dim r As String =UPDATE users SET username = N'& TextBox2.Text& ',密码= N'& TextBox3.Text& ',email ='& TextBox4.Text& ',mobile ='& Val(TextBox5.Text)& 'WHERE(user_no = N'& Session(user_no)&')
Com.CommandText = r
DR = Com.ExecuteReader
Do DR.Read
TextBox2.Text = DR(0)
TextBox3.Text = DR(1)
TextBox4.Text = DR(2)
TextBox5.Text = DR(3)
Com.Connection = conn
循环
DR.Close()
Com.ExecuteNonQuery()
conn.Close()

解决方案

你注意到哪个问题,我说不出来。

这可能是任何人都可以从世界的另一端摧毁你的数据库的方式。可能是你在文本框中什么都没得到。它可能是别的,我不知道,因为你不告诉我们。



但是。如果我是你,我会首先使用参数化查询来防止SQL注入攻击破坏你的数据库,然后查看UPDATE查询的作用。

因为它没有做的事情之一就是返回记录...

If conn.State = False Then
            conn.Open()
            Com.Connection = conn
            Com.CommandType = CommandType.Text
            Dim r As String = " UPDATE users SET username = N'" & TextBox2.Text & "', password= N'" & TextBox3.Text & "', email = '" & TextBox4.Text & "',mobile = '" & Val(TextBox5.Text) & "' WHERE (user_no = N'" & Session("user_no") & "') "
            Com.CommandText = r
            DR = Com.ExecuteReader
            Do While DR.Read
                TextBox2.Text = DR(0)
                TextBox3.Text = DR(1)
                TextBox4.Text = DR(2)
                TextBox5.Text = DR(3)
                Com.Connection = conn
            Loop
            DR.Close()
            Com.ExecuteNonQuery()
            conn.Close()

解决方案

Which problem you have noticed, I can't tell.
It could be the way anyone can destroy your database from the other side of the world. It could be that you get nothing in the text boxes. It could be something else, I don't know, because you don't tell y us.

But. If I was you I would start by using parametrised queries to prevent SQL injection attacks destroying your database, and then look at what an UPDATE query does.
Because one of the things it doesn't do is return records...


这篇关于更新stetment问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆