MS Access Bulk Insert exits app

Posted by Brij on Stack Overflow See other posts from Stack Overflow or by Brij
Published on 2010-12-28T12:25:39Z Indexed on 2010/12/28 12:54 UTC
Read the original article Hit count: 245

Filed under:
|
|
|
|

In the web service, I have to bulk insert data in MS Access database. First, There was single complex Insert-Select query,There was no error but app exited after inserting some records. I have divided the query to make it simple and using linq to remove complexity of query. now I am inserting records using for loop. there are approx 10000 records. Again, same problem. I put a breakpoint after loop, but No hit. I have used try catch, but no error found.

 For Each item In lstSelDel
            Try
                qry = String.Format("insert into Table(Id,link,file1,file2,pID) values ({0},""{1}"",""{2}"",""{3}"",{4})", item.WebInfoID, item.Links, item.Name, item.pName, pDateID)
                DAL.ExecN(qry)
            Catch ex As Exception
                Throw ex
            End Try    
        Next




Public Shared Function ExecN(ByVal SQL As String) As Integer

        Dim ret As Integer = -1
        Dim nowConString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.AppDomain.CurrentDomain.BaseDirectory + "DataBase\\mydatabase.mdb;"
        Dim nowCon As System.Data.OleDb.OleDbConnection
        nowCon = New System.Data.OleDb.OleDbConnection(nowConString)
        Dim cmd As New OleDb.OleDbCommand(SQL, nowCon)
        nowCon.Open()
        ret = cmd.ExecuteNonQuery()
        nowCon.Close()
        nowCon.Dispose()
        cmd.Dispose()
        Return ret
    End Function

After exiting app, I see w3wp.exe uses more than 50% of Memory. Any idea, What is going wrong? Is there any limitation of MS Access?

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET