我在 MySQL 中有一个名为database1的数据库和一个名为records的表。我正在尝试以列形式而不是以行形式将文本框(3 个文本框)上的内容添加到我的 MySQL 数据库中。
可以用concat
吗???
这是我的代码,我为 typeofservice2 和 typeofservice3 创建了一行,但我只想要一个,即服务类型,它看起来像这样 我做了什么
Query = "insert into database1.records (dateoftrans,typeofservice,typeofservice2,typeofservice3) values('" & TextBox12.Text & "','" & tos & "','" & tos2 & "','" & tos3 & "')"
tos、tos2 和 tos3 是我的文本框
希望有人能帮助我
最佳答案
起初这个问题对我来说相当棘手,但后来我明白了你的意思,我试了一下。
您当前的查询是这样的。
Query = "插入database1.records(dateoftrans,typeofservice,typeofservice2,typeofservice3)values('"& TextBox12.Text & "','"& tos & "','"& tos2 & "' ,'"& tos3 & "')"
我能给你的最好的方式就是这个.. 创建 3 x 插入命令,每个查询都有自己的 tos(文本框名称)。做这样的事情。
Query1 = 插入database1.records(dateoftrans,typeofservice)values('"& TextBox12.Text & "','"& tos & "')
Query2 = 插入database1.records(dateoftrans,typeofservice)values('"& TextBox12.Text & "','"& tos2 & "')
Query2 = 插入database1.records(dateoftrans,typeofservice)values('"& TextBox12.Text & "','"& tos3 & "')
这样您就可以将所有值保存在同一列中。
关于mysql - 如何以列形式显示多个文本框(vb net)中的值到mysql数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40905988/