vb.net 使用字符串处理许多表名
我将表名存储在字符串
ugad = "INSERT INTO tb(Ugname,Ugdob,Uggender)"
中,这是功能良好的普通查询。
但我需要将表名存储在名为“dept”的字符串中,
并且该字符串将在不同时间具有差异表名称。我应该如何运行它,我应该给出Wat查询。
ugad =“插入部门(Ugname,Ugdob,Uggender)” 我知道这个查询是无效的。我可以知道正确的查询吗
Am storing a table name in a String
ugad = "INSERT INTO tb(Ugname,Ugdob,Uggender)"
this is the ordinary query which functions well.
But i need to store a Tablename in a string called "dept"
and this string will have diff table name at diff times. How should i run it, Wat query should I Give.
ugad = "INSERT INTO dept(Ugname,Ugdob,Uggender)"
I know this query is not vaild. May i know the correct query
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用:
注意,可以说有比上述方法更安全、更好的方法来编写 SQL(如果您担心通过 SQL 注入恶意或意外干扰您的基础数据),但希望这可以帮助您入门。
Use:
N.B. There are arguably safer, better ways to compose SQL (if you are worried about malicious or accidental interference with your underlying data through SQL injection) than the above but hopefully that gets you started.
或者
我认为哪个更容易阅读并且更容易维护。
Or
Which I think is easier to read and easier to maintain.
如果我理解正确的话,你需要尝试类似
Have a llok at Operators in VB.NET
请记住,一旦开始循环连接,字符串连接可能会非常慢,因此请始终牢记 StringBuilder 类 存在,并且比普通连接快很多...
If I understand you correctly you neet to try something like
Have a llok at Operators in VB.NET
Just remember that string concatenation can be very slow once you start concatenating in loops, so always have in the back of your mind that the StringBuilder Class exists, and is a lot faster than normal concatenation...