If  understand your code correctly, this line creates a table with a single 
column.

        dbConn.createTable("CREATE TABLE " & tblName & "(" & fldName & " " &
        fldAttribute & ")")

You describe a user interface to be used to create tables with multiple columns.

You must do one of two things:

        1. delay the create table statement execution until all columns are
        known and can be included inside the parentheses, or

        2. perform the create for the first column and then use the alter table
        statement to append remaining columns, perhaps one at a time.

-----------

On Tue, 11 Jul 2006 10:57:36 +0100, John Newby wrote:

>Hi, I am creating a front-end to the sqlite DBMS using VB.Net 2002. I have
>managed to get the name of the table, field names and types from user input
>displayed into a listview but I can only get the Create table command to
>accept the last input values, so if the table has more than one field(which
>nealry every table has) it simply ignores the previously entered fields.

>How would I get it to create an SQL query with all the inputted field
>details?

>I have inserted the code I have used so far.

>Many thanks for your help.

>This button opens up a new form for the user to input the field name and
>select the field type then brings them back and displays them in a listview.


>Public Sub btnAddColumn_Click(ByVal sender As System.Object, ByVal e As
>System.EventArgs) Handles btnAddColumn.Click
>Dim frmAddColumns1 As New frmAddColumns()
>frmAddColumns1.ShowDialog(Me)
>fldName = frmAddColumns.ColumnNameTB.Text
>fldAttribute = frmAddColumns.ColumnTypeTB.SelectedItem
>'Create ListViewItem
>Dim item1 As New ListViewItem(fldName, 0)
>item1.SubItems.Add(fldAttribute)
>'Add the items to the ListView.
>listView1.Items.AddRange(New ListViewItem() {item1})
>Me.Controls.Add(listView1)
>End Sub

>This button takes the input table name, field name and attributes and
>creates the SQL command to send to the database to create the table:


>Private Sub btnCreateTable_Click(ByVal sender As System.Object, ByVal e As
>System.EventArgs) Handles btnCreateTable.Click
>Dim tblName As String
>tblName = txtTableName.Text.ToString()
>If Len(txtTableName.Text) < 1 Then
>MessageBox.Show("Please type a name for the table")
>ElseIf Len(txtTableName.Text) > 0 Then
>Try
>dbConn.openExistingDatabse("Data Source=" & getDBName() &
>";Version=3;New=False;Compress=True;")
>dbConn.createSQLCommand()
>dbConn.createTable("CREATE TABLE " & tblName & "(" & fldName & " " &
>fldAttribute & ")")
>MessageBox.Show("Table created successfully")
>Me.Close()
>Dim frmInsertData1 As frmInsertData = New frmInsertData()
>frmInsertData1.Show()
>Catch es As Exception
>MessageBox.Show(es.Message)
>End Try
>End If
>End Sub




Reply via email to