Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / DB Engine / SQL Server CE / September 2007

Tip: Looking for answers? Try searching our database.

URGENT: Not enough storage is available to complete this operation. - I am going crazy over this.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Loogie - 21 Sep 2007 19:17 GMT
I am trying to stop my app from crashing. I have read the
documentation and am disposing of everything properly. Can someone
please tell me why I get the following error:

System.Data.SqlServerCe.SqlCeException was unhandled
 HResult=-2147024882
 Message="Not enough storage is available to complete this
operation."
 NativeError=0
 Source="SQL Server Compact Edition ADO.NET Data Provider"
 StackTrace:
   at System.Data.SqlServerCe.SqlCeConnection.ProcessResults()
   at System.Data.SqlServerCe.SqlCeConnection.Open()
   at System.Data.SqlServerCe.SqlCeConnection.Open()
   at Pocket_Designer.Form10.MenuItem1_Click()
   at System.Windows.Forms.MenuItem.OnClick()
   at System.Windows.Forms.Menu.ProcessMnuProc()
   at System.Windows.Forms.Form.WnProc()
   at System.Windows.Forms.Control._InternalWnProc()
   at Microsoft.AGL.Forms.EVL.EnterMainLoop()
   at System.Windows.Forms.Application.Run()
   at Pocket_Designer.Form1.Main()

>From this code: (I made a notation in CAPS where the error fires)

'check to see if db exists
       Dim fi As FileInfo
       Dim SourceDir As String = "\Program Files\data\products"
       Dim source As DirectoryInfo = New DirectoryInfo(SourceDir)
       If Not source.Exists Then
           source.Create()
       End If

       Dim fiExists As Boolean
       fiExists = False

       For Each fi In source.GetFiles("*.sdf")
           If UCase(fi.Name) =
UCase(Trim(clsGlobals.Form4.txtName.Text) & ".sdf") Then
               fiExists = True
               Exit For
           End If
       Next

       Dim engine As New SqlCeEngine("Data Source = \Program Files
\data\products\" & Trim(clsGlobals.Form4.txtName.Text) & ".sdf")
       If fiExists = False Then
           'create database
           engine.CreateDatabase()
       End If

       ' open connection.

       Dim ssceconn As New SqlCeConnection("Data Source = \Program
Files\data\products\" & Trim(clsGlobals.Form4.txtName.Text) & ".sdf")
       ssceconn.Open()

       Dim sqlSeek As New SqlCeCommand("SELECT * FROM
INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'product' AND TABLE_TYPE
= 'TABLE'", ssceconn)
       Dim sqlCreateTable As SqlCeCommand = ssceconn.CreateCommand()
       Dim reader As SqlCeDataReader = sqlSeek.ExecuteReader()

       If reader.Read = False Then
           ' Create product table
           sqlCreateTable.CommandText = "CREATE TABLE product(p_item
int IDENTITY(1,1) PRIMARY KEY NOT NULL, p_code NVARCHAR(1) NOT NULL,
p_name NVARCHAR(255) NOT NULL, p_min numeric(3) NOT NULL, p_top
numeric(3) NOT NULL, p_sec int NOT NULL, p_len numeric(5,2) NOT NULL,
p_units NVARCHAR(10) NOT NULL, p_speclist NVARCHAR(100) NOT NULL,
p_notes NVARCHAR(255) NULL, p_verify NVARCHAR(3) NOT NULL)"
           sqlCreateTable.ExecuteNonQuery()

           'Create product species table
           sqlCreateTable.CommandText = "CREATE TABLE
prodspecies(s_item int IDENTITY(1,1) PRIMARY KEY NOT NULL, s_species
NVARCHAR(100) NOT NULL, s_code NVARCHAR(10) NOT NULL, s_type
NVARCHAR(10) NOT NULL, s_link NVARCHAR(3) NOT NULL, s_verify
NVARCHAR(3) NOT NULL, s_sort INT NOT NULL)"
           sqlCreateTable.ExecuteNonQuery()

           'Create Tally Table
           'note this table is not used until later on in process
           sqlCreateTable.CommandText = "CREATE TABLE tblTally(t_id
int IDENTITY(1,1) PRIMARY KEY NOT NULL, t_albl NVARCHAR(7) NOT NULL,
t_arqd NVARCHAR(8) NOT NULL, t_amoe NVARCHAR(6) NOT NULL, t_alst
NVARCHAR(100) NULL, t_akep NVARCHAR(3) NOT NULL, t_aprod NVARCHAR(100)
NOT NULL, t_adc INT NOT NULL, t_acomm NVARCHAR(100) NULL, t_atyp
NVARCHAR(9) NULL)"
           sqlCreateTable.ExecuteNonQuery()

       End If

       reader.Close()
       reader.Dispose()
       reader = Nothing

       sqlCreateTable.Dispose()
       sqlCreateTable = Nothing

       sqlSeek.Dispose()
       sqlSeek = Nothing

       ' Add product record

       '1. Check to see if record exists. If it does then update it
       '2. If it doe not exists then insert it

       If MenuItem1.Text = "Update Product  |" Then
           Dim sqlDeleteRow1 As SqlCeCommand = ssceconn.CreateCommand
           Dim sqlDeleteRow2 As SqlCeCommand = ssceconn.CreateCommand
           'delete product
           sqlDeleteRow1.CommandText = "DELETE FROM product WHERE
p_code ='" &
clsGlobals.Form4.lsvProds.Items(clsGlobals.Form4.lsvProds.SelectedIndices(0)).SubItems(1).Text
& "'"
           sqlDeleteRow1.ExecuteNonQuery()
           'delete species linked to this product
           sqlDeleteRow2.CommandText = "DELETE FROM prodspecies WHERE
s_link = '" &
clsGlobals.Form4.lsvProds.Items(clsGlobals.Form4.lsvProds.SelectedIndices(0)).SubItems(1).Text
& "'"
           sqlDeleteRow2.ExecuteNonQuery()

           sqlDeleteRow1.Dispose()
           sqlDeleteRow1 = Nothing

           sqlDeleteRow2.Dispose()
           sqlDeleteRow2 = Nothing
       End If

       Dim sqlInsertRow As SqlCeCommand = ssceconn.CreateCommand()
       sqlInsertRow.CommandText = "INSERT INTO product(p_code,
p_name, p_min, p_top, p_sec, p_len, p_units, p_speclist, p_notes,
p_verify) VALUES('" & cboCode.SelectedItem.ToString & "', '" &
Trim(txtName.Text) & "'," & txtMin.Text & "," & txtTop.Text & "," &
txtSec.Text & "," & txtLen.Text & ",'" &
clsGlobals.Form4.cboUnits.SelectedItem.ToString & "','" &
clsGlobals.Form4.cboSpecies.SelectedItem.ToString & "', '" &
txtNotes.Text & "', 'Yes')"
       sqlInsertRow.ExecuteNonQuery()

       sqlInsertRow.Dispose()
       sqlInsertRow = Nothing

       Dim strGetSpec As String
       strGetSpec = clsGlobals.Form4.cboSpecies.SelectedItem
       Dim SpecConn As New SqlCeConnection("Data Source = \Program
Files\data\species\" & ([clsGlobals].[Form4].[cboSpecies].SelectedItem
& ".sdf")
       SpecConn.Open() 'ERROR FIRES HERE ERROR FIRES HERE ERROR FIRES
HERE

       For i As Integer = 0 To lstIn.Items.Count - 1
           Dim cmdGetSpec As New SqlCeCommand("Select * from species
WHERE Code = '" & lstIn.Items(i) & "'", SpecConn)
           Dim readerGetSpec As SqlCeDataReader =
cmdGetSpec.ExecuteReader()
           Dim strSpecies As String
           Dim strType As String
           Dim Xint As Integer
           Dim strsqlSPEC As SqlCeCommand = ssceconn.CreateCommand()

           While readerGetSpec.Read
               strSpecies = readerGetSpec.Item("species").ToString
               strType = readerGetSpec.Item("type").ToString
               Xint = CInt(readerGetSpec.Item("spec_id").ToString)
               strsqlSPEC.CommandText = "INSERT INTO
prodspecies(s_species, s_code, s_type, s_link, s_verify, s_sort)
VALUES('" & strSpecies & "', '" & lstIn.Items.Item(i) & "', '" &
strType & "', '" & cboCode.SelectedItem.ToString & "', 'Yes',  " &
Xint & ")"
               strsqlSPEC.ExecuteNonQuery()
           End While

           readerGetSpec.Close()
           readerGetSpec.Dispose()
           readerGetSpec = Nothing
           cmdGetSpec.Dispose()
           cmdGetSpec = Nothing
       Next

       SpecConn.Close()
       SpecConn.Dispose()
       SpecConn = Nothing
Loogie - 22 Sep 2007 14:56 GMT
Just so everyone knows, the I added .dispose to all SqlCeCommands and
also removed unnecessary files from the device. It now works.

:L

> I am trying to stop my app from crashing. I have read the
> documentation and am disposing of everything properly. Can someone
[quoted text clipped - 181 lines]
>         SpecConn.Dispose()
>         SpecConn = Nothing
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.