如何使用选中的项目文本来创建SQL表 [英] How to use checked item text to make SQL table
本文介绍了如何使用选中的项目文本来创建SQL表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以这是我的问题,当我运行我的代码时,我在那里已经有一个名为'blank'的对象在数据库中,但当我去检查看到添加到表中的内容时它只接受1个已检查的有人可以帮我解决这个问题请
So here is my problem, when I run my code I get there is already an object named 'blank" in the database, but when I go to check to see what was added into the table it only accepts 1 of the checked box items. Can someone help me with this issue please
For Each list As String In CheckedListBox1.CheckedItems
CheckState.Checked.ToString()
sqlcon.Open()
Dim cmd As SqlClient.SqlCommand
Dim sql As String = "CREATE TABLE" + "[" + St + "]" + "(Id INTEGER Not Null PRIMARY KEY CLUSTERED ([Id] ASC)," + list.ToString + " NVARCHAR (MAX) NULL)"
cmd = New SqlClient.SqlCommand(sql, sqlcon)
我的尝试:
我试图将每个语句切换为每个语句的选择项。这不起作用。
What I have tried:
I have tried to switch the for each statement to a selecteditems for each statement. which didnt work.
推荐答案
问题是你是试着g一遍又一遍地创建相同的表:所有表具有相同的表名。 SQL不允许你这样做:你不能拥有两个与SQL同名的表,当你试图访问其中一个时,不知道你指的是哪一个。
The problem is that you are trying to create the same table over and over again: all with the same table name. SQL won't let you do that: you cannot have two tables with the same name as SQL wouldn't know which one you were referring to when you tried to access one of them.
这篇关于如何使用选中的项目文本来创建SQL表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文