Click here to Skip to main content
15,900,378 members
Home / Discussions / C#
   

C#

 
AnswerRe: problem in C# Pin
led mike6-May-09 4:37
led mike6-May-09 4:37 
AnswerRe: problem in C# Pin
Luc Pattyn6-May-09 4:38
sitebuilderLuc Pattyn6-May-09 4:38 
QuestionCrystal report binding Pin
KIDYA6-May-09 3:31
KIDYA6-May-09 3:31 
QuestionHTK Pin
dileeparuwan6-May-09 3:25
dileeparuwan6-May-09 3:25 
QuestionUsing Cell Phone as a PC Microphone in using in the hand 32feet Pin
Ami Vaknin6-May-09 3:21
Ami Vaknin6-May-09 3:21 
AnswerRe: Using Cell Phone as a PC Microphone in using in the hand 32feet Pin
Henry Minute6-May-09 6:21
Henry Minute6-May-09 6:21 
GeneralRe: Using Cell Phone as a PC Microphone in using in the hand 32feet Pin
Ami Vaknin6-May-09 11:16
Ami Vaknin6-May-09 11:16 
QuestionOut of Memory exception.. Pin
Jacob Dixon6-May-09 3:16
Jacob Dixon6-May-09 3:16 
When I drop an item into a ListView I get an out of memory exception... but... I have them on the same form.. within the same TabControl (different tabs though).

Basically I am saving the file... if the item is to be sent to M&R then I set the MR column (BIT) to True, and if not, then False. This way I can tell which ListView the item should show up in... But I get an error on the drag and dropping to the second listview (the M&R one)

private void listViewFiles_DragDrop(object sender, DragEventArgs e)
{
    string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
    foreach (string file in files)
    {
        newFile = new OpenFileDialog();
        newFile.FileName = file;
        SaveFileThread(file, newFile.SafeFileName, false);
        newFile.Dispose();
    }
    bwLoadFiles.RunWorkerAsync();
}
private void lstMRFiles_DragDrop(object sender, DragEventArgs e)
{
    string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
    foreach (string file in files)
    {
        newFile = new OpenFileDialog();
        newFile.FileName = file;
        SaveFileThread(file, newFile.SafeFileName, true);
        newFile.Dispose();
    }
    bwLoadFiles.RunWorkerAsync();
}




Here is what it is calling:

private void SaveFileThread(string Filename, string SafeFile, bool MR)
 {
     RegistryAccess reg = new RegistryAccess();
     SqlConnection conn = new SqlConnection(reg.ReturnConnection);
     SqlCommand cmd = new SqlCommand("SELECT * FROM Inventory_Files WHERE FilesID=@FilesID AND [Filename]=@Filename AND MR=@MR", conn);

     try
     {
         cmd.Parameters.AddWithValue("@FilesID", txtTAG.Text);
         cmd.Parameters.AddWithValue("@Filename", SafeFile);
         cmd.Parameters.AddWithValue("@MR", MR);

         conn.Open();
         SqlDataReader myReader = cmd.ExecuteReader();

         if (myReader.HasRows)
         {
             if (MR) Invoke(new FilesLabelDelegate(FilesLabel), new object[] { "Did not save. File already exist.", true });
             else Invoke(new FilesLabelDelegate(FilesLabel), new object[] { "Did not save. File already exist.", false });
         }
         else
         {
             conn.Close();
             FileStream fs = new FileStream(Filename, FileMode.Open, FileAccess.Read);

             decimal Size = fs.Length;
             byte[] buffer = new byte[fs.Length];
             fs.Read(buffer, 0, (int)fs.Length);
             fs.Close();

             if (MR) Invoke(new FilesLabelDelegate(FilesLabel), new object[] { "Saving file.. Size: " + Math.Round((Size / 1024) / 1024, 2) + "MB", true });
             else Invoke(new FilesLabelDelegate(FilesLabel), new object[] { "Saving file.. Size: " + Math.Round((Size / 1024) / 1024, 2) + "MB", false });

             conn = new SqlConnection(reg.ReturnConnection);
             cmd = new SqlCommand("INSERT INTO Inventory_Files (FilesID, Saved_File, Filename, File_Size, MR) VALUES (@FilesID, @File, @FileName, @Size, @MR)", conn);
             cmd.Parameters.AddWithValue("@FilesID", txtTAG.Text);
             cmd.Parameters.AddWithValue("@File", buffer);
             cmd.Parameters.AddWithValue("@FileName", SafeFile);
             cmd.Parameters.AddWithValue("@Size", Size);
             cmd.Parameters.AddWithValue("@MR", MR);
             conn.Open();

             int Success = cmd.ExecuteNonQuery();

             if (Success > 0)
             {
                 if (MR) Invoke(new FilesLabelDelegate(FilesLabel), new object[] { "Saved file.", true });
                 else Invoke(new FilesLabelDelegate(FilesLabel), new object[] { "Saved file.", false });
             }
         }
     }
     catch (Exception ex) { new Errors(ex).ShowDialog(); }
     finally { conn.Close(); }
 }

AnswerRe: Out of Memory exception.. Pin
S. Senthil Kumar6-May-09 9:09
S. Senthil Kumar6-May-09 9:09 
GeneralRe: Out of Memory exception.. Pin
Jacob Dixon6-May-09 10:18
Jacob Dixon6-May-09 10:18 
GeneralRe: Out of Memory exception.. Pin
S. Senthil Kumar6-May-09 10:25
S. Senthil Kumar6-May-09 10:25 
QuestionReading large xls files in C# Pin
aastudent6-May-09 3:08
aastudent6-May-09 3:08 
AnswerRe: Reading large xls files in C# Pin
foluis26-Mar-10 11:16
foluis26-Mar-10 11:16 
GeneralRe: Reading large xls files in C# Pin
aastudent28-Mar-10 21:47
aastudent28-Mar-10 21:47 
GeneralRe: Reading large xls files in C# Pin
foluis29-Mar-10 8:22
foluis29-Mar-10 8:22 
QuestionConverting C source code into C# source code Pin
dileeparuwan6-May-09 3:05
dileeparuwan6-May-09 3:05 
AnswerRe: Converting C source code into C# source code Pin
musefan6-May-09 3:13
musefan6-May-09 3:13 
GeneralRe: Converting C source code into C# source code Pin
dileeparuwan6-May-09 3:17
dileeparuwan6-May-09 3:17 
AnswerRe: Converting C source code into C# source code Pin
Dave Doknjas6-May-09 12:53
Dave Doknjas6-May-09 12:53 
Questioncall Oracle function which returns a REF CURSOR - tutorial? Pin
devvvy6-May-09 2:59
devvvy6-May-09 2:59 
AnswerRe: call Oracle function which returns a REF CURSOR - tutorial? Pin
TweakBird28-Dec-10 22:09
TweakBird28-Dec-10 22:09 
Questionsource code for video cutter Pin
twinkle116-May-09 2:58
twinkle116-May-09 2:58 
AnswerRe: source code for video cutter Pin
dheeraj.mittal3-Jun-10 19:35
dheeraj.mittal3-Jun-10 19:35 
QuestionLaunch Condition for crystal report in c#.net 3.5 Setup project. Pin
Narendra Reddy Vajrala6-May-09 2:18
Narendra Reddy Vajrala6-May-09 2:18 
AnswerRe: Launch Condition for crystal report in c#.net 3.5 Setup project. Pin
bhaumikdv25-May-09 22:46
bhaumikdv25-May-09 22:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.