且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

需要帮助我的代码

更新时间:2023-11-20 15:20:40

你需要用单个单引号重复双引号:

You need to replce the double quotes with single:
Str = "insert into TRAINS values("
Str += "'" & TextBox1.Text.Trim() & "',"
Str += "'" & TextBox2.Text.Trim() & "',"
Str += "'" & TextBox3.Text.Trim() & "',"
Str += "'" & TextBox4.Text.Trim() & "',"
Str += "'" & TextBox5.Text.Trim() & "',"
Str += "'" & TextBox6.Text.Trim() & "',"
Str += "'" & TextBox7.Text.Trim() & "')"



但不要'这样做!不要连接字符串以构建SQL命令。它让您对意外或故意的SQL注入攻击持开放态度,这可能会破坏您的整个数据库。改为使用参数化查询。



哦,不要使用VS默认名称!您可能还记得今天哪个文本框会产生什么,但是在三周之后呢?使用合理的名字!


But don't do it that way! Do not concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead.

Oh, and don't use VS default names for everything! You may remember which textbox hodls what today, but in three weeks time? Use sensible names!