Click here to Skip to main content
15,909,530 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello
I have a problem when making of entering from one form to another appears to me an error "not enough storage is available to complete this operation" if someone can help me, a programming language in which I work is c #

[OP's answer moved to here]
The device on which work is Motorola MC75 has enough memory over 90MB, and all processes in the TaskManager off
C#
namespace MotorolaSmartphon
{
   public partial class Form1 : Form
   {
      private GPS sl = null;
      private Symbol.Barcode.Reader myReader = null;
      private Symbol.Barcode.ReaderData myReaderData = null;
      public string id_unosa;

      public Form1()
      {
         InitializeComponent();
         BarcodFunkcija();
         FunkcijaZaUcitavanje();
      }
 
      private void menuItem1_Click(object sender, EventArgs e)
      {
         this.Close();
      }
 
      private void Form1_Load(object sender, EventArgs e)
      {
         FunkcijaZaUcitavanje();
      }

      public void BarcodFunkcija()
      {
         myReader = new Symbol.Barcode.Reader();
         myReaderData = new Symbol.Barcode.ReaderData(Symbol.Barcode.ReaderDataTypes.Text, 7905);
         myReader.Actions.Enable();
         myReader.ReadNotify += new EventHandler(myReader_ReadNotify);
         myReader.Actions.Read(myReaderData);
      }

      void myReader_ReadNotify(object sender, EventArgs e)
      {
         Symbol.Barcode.ReaderData nextReaderData = myReader.GetNextReaderData();
         this.textBox1.Text = nextReaderData.Text;
         myReader.Actions.Read(myReaderData);
         SqlCeConnection connn = null;
         connn = new SqlCeConnection(@"Data Source=" + GetExePath() + "\\MC75.sdf");
         try
         {
            connn.Open();
         }
         catch (Exception ex)
         {
            MessageBox.Show(ex.ToString());
         }
         SqlCeCommand cmd = connn.CreateCommand();
         try
         {
            cmd.CommandText = ("INSERT INTO Unos(Barcod) values" + "(" + nextReaderData.Text + ")");
            cmd.ExecuteNonQuery();
         }
         catch (Exception ex)
         {
            //MessageBox.Show(ex.ToString());
         }
         dataGrid1.DataSource = FunkcijaZaUcitavanje();
         connn.Close();
      }

      static DataTable FunkcijaZaUcitavanje()
      {
         string SqlCeConnection = (@"Data Source=" + GetExePath() + "\\MC75.sdf");
         SqlCeConnection sqlConnection = new SqlCeConnection(SqlCeConnection);
         sqlConnection.Open();
         SqlCeDataAdapter sqlCommand = new SqlCeDataAdapter("select * from unos", sqlConnection);
         DataTable tabelazagrid = new DataTable();
         sqlCommand.Fill(tabelazagrid);
         return tabelazagrid;
      }

      static string GetExePath()
      {
         return (System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase));
      }
 
      private void Form1_Closing(object sender, CancelEventArgs e)
      {
         myReader.Actions.Flush();
         myReader.Actions.Disable();
         myReaderData.Dispose();
         myReader.Dispose();
      }
      
      private void button1_Click(object sender, EventArgs e)
      {
         try
         {
            myReader.Dispose();
         }
         catch (Exception exx)
         {
         }
         string p;
         p = takePicture();
      }
 
      private string takePicture()
      {
         string result = null;
         CameraCaptureDialog cameraDialog = new CameraCaptureDialog();
         cameraDialog.Mode = CameraCaptureMode.Still;
         cameraDialog.StillQuality = CameraCaptureStillQuality.High;
         cameraDialog.Resolution = new Size(640, 480);
         if (cameraDialog.ShowDialog() == DialogResult.OK)
         {
            result = cameraDialog.FileName;
         }
         this.Show();
         cameraDialog.Dispose();
         return result;
      }
 
      private void button3_Click(object sender, EventArgs e)
      {
         BarcodFunkcija();
      }
 
      private void DeleteDataMenuItem_Click_Click(object sender, EventArgs e)
      {
         SqlCeConnection connn = null;
         DialogResult result3 = MessageBox.Show("Brisanje izabranog reda?", "The Question", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question,
MessageBoxDefaultButton.Button2);
         if (result3 == DialogResult.Yes)
         {
            connn = new SqlCeConnection(@"Data Source=" + GetExePath() + "\\MC75.sdf");
            try
            {
               SqlCeCommand SL = new SqlCeCommand(" DELETE FROM Unos where ID = " + Convert.ToInt32(id_unosa), connn);
               connn.Open();
               SL.ExecuteScalar();
               connn.Close();
            }
            catch (SqlCeException ex)
            {
               MessageBox.Show(ex.Message.ToString());
            }
            finally
            {
               FunkcijaZaUcitavanje();
               connn.Close();
            }
         }
      }
 
      private void dataGrid1_Click(object sender, EventArgs e)
      {
         id_unosa = dataGrid1[dataGrid1.CurrentCell.RowNumber, dataGrid1.CurrentCell.ColumnNumber].ToString();
      }

      private void button2_Click_1(object sender, EventArgs e)
      {
         GPS GPS = new GPS();
         GPS.Show();
      }
   }
}
Posted
Updated 1-Mar-12 10:29am
v3

1 solution

Seems you should invest in some more RAM, try to kill all other processes. Maybe you have to check for enough free disc space, but I think it's because of not enough RAM.

Regards
 
Share this answer
 
Comments
LG0 1-Mar-12 7:48am    
I have enough memory, when I switch from one form that I used to read the barcode in the second of which reads GPS position error throw
El_Codero 1-Mar-12 7:54am    
Could you provide some more details please?Win7?VS 2010?RAM?
Maybe a Memory Leak? Please have a look at your TaskManager to monitor ram usage when switching your forms. I think we need some code ;)
El_Codero 1-Mar-12 19:02pm    
Could you provide us your GPS Class? Anyway, you call FunkcijaZaUcitavanje() Method two times (in Form1() AND Form1_Load)?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900