I want to create table in SQL2012 at run-time. My design form look like -
================================================
| chklstbox | | dbo.myTable |
|-------------------| |---------------------------------|
|x Apple | |myDate Date NOT NULL
|
|x Banana | VB.net |Apple varchar(20) |
| Cake | ======> |Banana varchar(20) |
|x Lime | |Lime varchar(20) |
| Icream | |____________________ |
|____________|
============================================
Dim CmdCreate as String
Dim conn as New SqlConnection("Data Source="My-PC";Initial Catalog=MyDatabase;Integrated Security=True;Pooling=False")
CmdCreate = "CREATE TABLE myLst (myDate Date NOT NULL)"
For Each i As String In chklst.CheckedItems
CmdCreate = "ALTER TABLE myLst ADD (" & chklst.Items.IndesOf(i) & " varchar(20))"
Next
Dim oCmd AS New SqlCommand(cmdCrate, conn)
oCmd.CommandType = CommandType.Text
oCmd.ExecuteNonQuery()
conn.Close()