Results 1 to 9 of 9

Thread: copying table problems

  1. #1
    Myrrdan
    Guest

    copying table problems

    Ok, I had this working, now it gives me error whenever i try to copy the table.
    this is the code that gives me troubles.
    vb code:
    strFolder = InputBox("What name of directory?" & vbCrLf & "NO SPACES!!", "CD Folder Name", strPath)

    strcommand = "SELECT * INTO " & strFolder & " FROM default"

    On Error GoTo Error
    dbsFiles.Execute strcommand

    it hits the dbsFiles.execute strcommand and tells me the variable not defined error.
    I have no idea why.. It was working, would grab whatever you typed into the message box for the table name, then drop the files into that table.
    AHHHHHHHH help...

    I need it to grab each file and drop it into a new table. I'd use 1 table, but there are going to be hundreds if not over a thousand files listed.... I need the option to change the filename as well...

  2. #2
    Hyperactive Member
    Join Date
    Mar 02
    Location
    ON, CAN
    Posts
    265
    helllo,
    you have to provide the path to the database in the IN clause

    "SELECT * INTO table IN " & strFolder & " FROM source"

    Regan
    For excellent Winsock example check here WINSOCK

  3. #3
    Myrrdan
    Guest

    IN clause

    So i'd need somethign like

    SELECT * INTO table IN " & strFolder & " FROM source"

    but would i need to replace table with the name of the table, and strFolder with the path to the database....

    hm. i'm not sure whats wrong, I had it without the table IN before and it worked fine. I'll try this see if it works.
    Thanks

  4. #4
    Hyperactive Member
    Join Date
    Mar 02
    Location
    ON, CAN
    Posts
    265
    but would i need to replace table with the name of the table, and strFolder with the path to the database....
    yep!

    let me know if you have any more questions,

    Regan
    For excellent Winsock example check here WINSOCK

  5. #5
    Myrrdan
    Guest
    ahhhhh!!!!!!
    nothing is working...
    i can't even get the database to open.
    I took ppl's suggestion and made 1 table, with 3 fields, number.name,directory..
    the table is called default...

    dbsFiles is declared as database, and is in the code as the database to open...

    but it keeps telling me variable not set...
    how do i declare dbsfiles as the database i want....

    I have no idea what I am doing, i checked out the tutorials and didn't help any.

    It was working, buyt today my brain just isn't working...

  6. #6
    Hyperactive Member
    Join Date
    Mar 02
    Location
    ON, CAN
    Posts
    265
    you have to instantiate the object using the Set and New keywords. However, you can do it all in one step, but you loose control when over the object and when it actually created.


    say you wanted to declare a new recordset object, try

    ' Declare object

    Dim Recordset as Adodb.recordset

    ' intantiate/create the object

    set recordset = new adodb.recordset

    ' to relase memory

    set recordset = nothing

    opps, are you using DAO?

    Regan
    For excellent Winsock example check here WINSOCK

  7. #7
    Myrrdan
    Guest
    I've gotten this code to go with ADO
    unfortunately it errors out the set dbsfiles = new adodb.connection....
    it doens't have adodb listed, just adox

    Set dbsFiles = New ADODB.Connection

    With dbsFiles

    .CursorLocation = adUseClient

    .Provider = "Microsoft Jet 4.0 OLE DB Provider"

    .ConnectionString = "Data Source=" & dbFilename

    .Open

    End With

    Set rcdRecords = dbsFiles.OpenRecordset(txtDatabase.Text)

    For inti = 0 To filFile.ListCount - 1
    filFile.ListIndex = inti
    rcdRecords.AddNew
    strFileName = filFile.FileName
    strDirectory = dirDir.Path
    rcdRecords(0) = filFile.FileName
    rcdRecords.Update
    Next inti

    rcdRecords.Close
    dbsFiles.Close

  8. #8
    Hyperactive Member
    Join Date
    Mar 02
    Location
    ON, CAN
    Posts
    265
    hello,

    did you set the reference to the Activex data objects library?

    if not open vb, clickt the Project menu, then references, then scroll down untile you see Microsoft Activex Data Object 2.x and double click one

    good luck
    Regan
    For excellent Winsock example check here WINSOCK

  9. #9
    Myrrdan
    Guest
    kewl, that cut the errors, now how do i add records to the database..
    i need to grab filenames, directory structure.
    Into the 2nd and 3rd fields, the first is auto-number index

Posting Permissions

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