Results 1 to 2 of 2

Thread: Batch Inserts in MSACCESS

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    Brooklyn, NYC
    Posts
    112

    Angry Batch Inserts in MSACCESS

    Try doing this in VB application

    For intCounter = 1 To ClassInfos.Count
    strSQL = strSQL & " Insert into Class(ClassID,ProgramID,StudentID) Values("
    strSQL = strSQL & "'" & ClassInfos.Item(intCounter).ClassID & "','" & PInfo.ProgramID & "','" & SInfo.StudentID & "')" & vbCrLf
    Debug.Print strSQL
    Next intCounter

    adoCmd.CommandText = strSQL
    adoCmd.CommandType = adCmdText
    adoCmd.Execute (intRecs)



    Stupid MSACCESS dont accept batch inserts!! what the hell!!
    Visual Basic Programmer.

    VB,ASP,VBscript,JavaScript,Oracle,Developer 2000,ADO,HTML, C#, VB.NET, ASP.NET....

  2. #2
    Fanatic Member
    Join Date
    Jun 2003
    Location
    IL
    Posts
    739
    I never tried doing a batch insert, but you can always just do an excute statement inside the for loop instead. But you would have to make sure your first assigment statement to strSQL doesn't include itself.

    VB Code:
    1. For intCounter = 1 To ClassInfos.Count
    2. strSQL = " Insert into Class(ClassID,ProgramID,StudentID) Values("
    3. strSQL = strSQL & "'" & ClassInfos.Item(intCounter).ClassID & "','" & PInfo.ProgramID & "','" & SInfo.StudentID & "')" & vbCrLf
    4. adoCmd.Execute strSQL
    5. Debug.Print strSQL
    6. Next intCounter

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