Results 1 to 2 of 2

Thread: Created Table! How to add records?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    Created Table! How to add records?

    Ok, I have used the following code to create a new table in my "kamo.mdb". Now that I have it set up, how can I add information to the columns? I read the info from the file and save the results as strings. I want to use these strings to create records in my table now. Say I have this:

    strFilePath= "c:\my files"
    strFileName= "Music.mp3"
    etc.

    I Want to add each string to it's corresponding column in the table. The code below should explain what I'm trying to do better. Any help is appreciated.
    VB Code:
    1. Dim cat As New ADOX.Catalog
    2.    Dim tbl As New ADOX.Table
    3.  
    4.    ' Open the catalog
    5.    cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    6.       "Data Source=.\kamo.mdb;"
    7.  
    8.    ' Create a new Table object.
    9.    With tbl
    10.       .Name = categories.txtcategory.Text
    11.       ' Create fields and append them to the new Table
    12.       ' object. This must be done before appending the
    13.       ' Table object to the Tables collection of the
    14.       ' Catalog.
    15.       .Columns.Append "FilePath", adVarWChar
    16.       .Columns.Append "FileName", adVarWChar
    17.       .Columns.Append "Filesize", adVarWChar
    18.       .Columns.Append "Artist", adVarWChar
    19.       .Columns.Append "Title", adVarWChar
    20.       .Columns.Append "Album", adVarWChar
    21.       .Columns.Append "Frequency", adVarWChar
    22.       .Columns.Append "Bitrate", adVarWChar
    23.       .Columns.Append "Length", adVarWChar
    24.       .Columns.Append "Track#", adVarWChar
    25.       .Columns("Notes").Attributes = adColNullable
    26.    End With
    27.  
    28.    ' Add the new table to the database.
    29.    cat.Tables.Append tbl
    30.  
    31.    Set cat = Nothing

  2. #2
    hellswraith
    Guest
    Use a insert SQL statement.

    http://www.w3schools.com/sql/sql_insert.asp

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width