这个代码是否正确

编程入门 行业动态 更新时间:2024-10-23 13:22:57
本文介绍了这个代码是否正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

Try Dim sql As String = "SELECT MAX(ppo_no) FROM Pension_Master where state_code= '" & TextBox9.Text & "' " Dim comm As SqlCommand = New SqlCommand(sql, myconn) myReader = comm.ExecuteReader If myReader.HasRows Then While myReader.Read() temp = myReader.Item("TextBox5.Text") + ("TextBox9.Text") End While End If Catch ex As Exception End Try TextBox8.Text = String.Concat(temp) 'TextBox8.Text = TextBox5.Text & TextBox9.Text myReader.Close() cmd.ExecuteNonQuery()

推荐答案

看看你的代码,我会说不,这不正确。 你实际上想做什么,因为我不相信while循环中的代码会起作用,cmd.ExecuteNonQuery ()在方法结束时似乎没必要。 代码也对SQL注入攻击开放。 Looking at your code, I would say No it's not correct. What are you actually trying to do because I do not believe that the code in the while loop will work, and cmd.ExecuteNonQuery() seems unnecessary at the end of the method. The code is also open to SQL Injection attacks.

否和在很多层面上,我没有足够的空间在论坛帖子中,或者时间打字,列出所有。 你也没有指定您对答案的适应性。代码是否适用于你想要做的任何事情?可能不是。我们无法回答这个问题,因为你还没有说过这个代码应该做什么。 它是否安全?至少。 生产质量如何?无处附近。 拿起一本关于VB.NET的初学者书并通过它完成。 No and on so many levels I don't have sufficient space in a forum post, or time to type them all up, to list them all. You also don't specify to what "fitness" you expect for an answer. Does the code work for whatever it is you're trying to make it do? Probably not. We can't answer this as you haven't said anything about what this code is supposed to do. Is it secure? Not in the least. Is it production quality? Nowhere near it. Pickup a beginners book on VB.NET and work through it.

更多推荐

这个代码是否正确

本文发布于:2023-11-08 07:03:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1568675.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:是否正确   代码

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!