Click here to Skip to main content
15,908,020 members
Home / Discussions / C#
   

C#

 
GeneralRe: Datagrid print location help [REPOST attempt to bump] Pin
spankyleo12313-Aug-09 10:18
spankyleo12313-Aug-09 10:18 
QuestionI am having issues with pictures and sql server can someone help me understand what is going on. [modified] Pin
JollyMansArt13-Aug-09 6:36
JollyMansArt13-Aug-09 6:36 
AnswerRe: I am having issues with pictures and sql server can someone help me understand what is going on. Pin
Luc Pattyn13-Aug-09 6:49
sitebuilderLuc Pattyn13-Aug-09 6:49 
GeneralRe: I am having issues with pictures and sql server can someone help me understand what is going on. Pin
JollyMansArt13-Aug-09 6:55
JollyMansArt13-Aug-09 6:55 
GeneralRe: I am having issues with pictures and sql server can someone help me understand what is going on. Pin
Luc Pattyn13-Aug-09 7:05
sitebuilderLuc Pattyn13-Aug-09 7:05 
GeneralRe: I am having issues with pictures and sql server can someone help me understand what is going on. [modified] Pin
JollyMansArt13-Aug-09 7:27
JollyMansArt13-Aug-09 7:27 
AnswerRe: I am having issues with pictures and sql server can someone help me understand what is going on. Pin
Henry Minute13-Aug-09 7:20
Henry Minute13-Aug-09 7:20 
GeneralRe: I am having issues with pictures and sql server can someone help me understand what is going on. Pin
JollyMansArt13-Aug-09 8:29
JollyMansArt13-Aug-09 8:29 
OK I have taken you advice from the website and I am still having issues with the Invalid Parameter. What is wrong?

private void pictureBox3_DoubleClick(object sender, EventArgs e)
    {
        intASUserListSelectedIndex = lbxAssistSuiteUserList.SelectedIndex;
        bool FoundUser = false;
        FileDialog fldlg = new OpenFileDialog();
        //specify your own initial directory

        if (lbxAssistSuiteUserList.SelectedIndex > -1)
        {
            try
            {
                fldlg.InitialDirectory = @":C\";
                //this will allow only those\ file extensions to be added
                fldlg.Filter = "Image File (*.jpg;*.bmp;*.gif)|*.jpg;*.bmp;*.gif|(*.gif)|*.gif|(*.jpg)|*.jpg|(*.jpeg)|*.jpeg|(*.bmp)|*.bmp|(*.wmf)|*.wmf|(*.png)|*.png";
                //fldlg.ShowDialog();
                if (fldlg.ShowDialog() == DialogResult.OK)
                {
                    imagename  = fldlg.FileName;
                    Bitmap newimg = new Bitmap(imagename);
                    pictureBox3.SizeMode = PictureBoxSizeMode.Zoom;
                    pictureBox3.Image =(Image)newimg;
                    //pictureBox3.Image = System.Drawing.Image.FromFile(openFileDialog1.FileName);
                    pictureBox3.Refresh();

                    //Update the SQL Tables.
                    lbxAssistSuiteUserList.SelectedIndex = intASUserListSelectedIndex;
                    btnUpdateAssistUsers_Click(sender, e);
                    lbxAssistSuiteUserList.SelectedIndex = intASUserListSelectedIndex;
                    updatedata();
                }


                fldlg = null;
                lbxAssistSuiteUserList.SelectedIndex = intASUserListSelectedIndex;
            }
            catch (System.ArgumentException ae)
            {
                imagename = " ";
                MessageBox.Show(ae.Message.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
    }

private void updatedata()
{
    SqlCommand cmd;
    bool FoundMe = false;
    int UserIndex = -1;
//use filestream object to read the image.
//read to the full length of image to a byte array.
//add this byte as an oracle parameter and insert it into database.


    try
    {
        if (imagename != "")
        {
            SqlConnection cn = new SqlConnection(WhatIsMyConnectionString);
                            for (i = 0; i < ApplicationUsersArray.Count; i++)
        {
            if (((DomainUsersClass)ApplicationUsersArray[i]).WindowsLogonName == lbxAssistSuiteUserList.Items[lbxAssistSuiteUserList.SelectedIndex].ToString())
            {
                FoundMe = true;
                break;
            }
        }
        if (FoundMe = true)
        {
            if (((DomainUsersClass)ApplicationUsersArray[i]).PicIndex == "")
            {
                UserIndex = Convert.ToInt32(((DomainUsersClass)ApplicationUsersArray[i]).Index);
                //SqlCommand cmd =  new SqlCommand("INSERT INTO tblApplicationUsersPic (id_image,BLOBData) VALUES ('" + UserIndex.ToString() + "'," + " @BLOBData)", cn);
                cmd =  new SqlCommand("INSERT INTO tblApplicationUsersPic (id_image,BLOBData) VALUES ('" + UserIndex.ToString() + "'," + " @BLOBData)", cn);
                //query = "insert into tblApplicationUsersPic(id_image,pic) values(" + UserIndex.ToString() + "," + " @pic)";
                //query = "insert into tblApplicationUsersPic(id_image,pic) values(@i, @p)";

            }
            else
            {
                UserIndex = Convert.ToInt32(((DomainUsersClass)ApplicationUsersArray[i]).Index);
                //SqlCommand cmd =  new SqlCommand("update tblApplicationUsersPic set pic = @BLOBData where id_image = '" + UserIndex.ToString() + "' ", cn);
                cmd =  new SqlCommand("update tblApplicationUsersPic set pic = @BLOBData where id_image = '" + UserIndex.ToString() + "' ", cn);
                //query = "update tblApplicationUsersPic set pic = @pic where id_image = '" + UserIndex.ToString() + "' ";
                //query = "update tblApplicationUsersPic set pic = @p where id_image = @i";
            }
        }
        else
        {
            MessageBox.Show("We have a serious problem. This should Never Happen. \n The Array did not find the correct users to grab their index for the Picture. \n The Application will now quit.");
            return;
        }
            //SqlCommand cmd =  new SqlCommand("INSERT INTO BLOBTest (BLOBData) VALUES (@BLOBData)", cn);
            String strBLOBFilePath = @imagename;//Modify this path as needed.

            //Read jpg into file stream, and from there into Byte array.
            FileStream fsBLOBFile =  new FileStream(strBLOBFilePath,FileMode.Open, FileAccess.Read);
            Byte[] bytBLOBData = new Byte[fsBLOBFile.Length];
            fsBLOBFile.Read(bytBLOBData, 0, bytBLOBData.Length);
            fsBLOBFile.Close();

            //Create parameter for insert command and add to SqlCommand object.
            SqlParameter prm = new  SqlParameter("@BLOBData", SqlDbType.VarBinary, bytBLOBData.Length, ParameterDirection.Input, false,
                        0, 0, null, DataRowVersion.Current, bytBLOBData);
            cmd.Parameters.Add(prm);

            //Open connection, execute query, and close connection.
            cn.Open();
            cmd.ExecuteNonQuery();
            cn.Close();

            if (FoundMe = true)
            {
                SQLUpdate(WhatIsMyConnectionString, "tblApplicationUsers", "tblApplicationUsersPic_idx = (Select idx_tblApplicationUserPic from tblApplicationUsersPic where id_image = '" + UserIndex.ToString() + "') ","delflag = 0 and idx_tblApplicationUsers = '" + UserIndex.ToString() + "' ");
                //UserIndex = Convert.ToInt32(((DomainUsersClass)ApplicationUsersArray[i]).Index);

            }
        }
    }
            catch (System.ArgumentException ae)
            {
                imagename = " ";
                MessageBox.Show(ae.Message.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
    }

GeneralRe: I am having issues with pictures and sql server can someone help me understand what is going on. Pin
Henry Minute13-Aug-09 8:38
Henry Minute13-Aug-09 8:38 
AnswerRe: I am having issues with pictures and sql server can someone help me understand what is going on. Pin
JollyMansArt13-Aug-09 7:44
JollyMansArt13-Aug-09 7:44 
GeneralRe: I am having issues with pictures and sql server can someone help me understand what is going on. Pin
Luc Pattyn13-Aug-09 8:34
sitebuilderLuc Pattyn13-Aug-09 8:34 
QuestionActive X Control... Pin
priyareguri13-Aug-09 6:00
priyareguri13-Aug-09 6:00 
AnswerRe: Active X Control... Pin
Dave Kreskowiak13-Aug-09 7:12
mveDave Kreskowiak13-Aug-09 7:12 
GeneralRe: Active X Control... Pin
priyareguri18-Aug-09 3:21
priyareguri18-Aug-09 3:21 
QuestionGetRelativePath implementation ? Pin
Marc Clifton13-Aug-09 5:54
mvaMarc Clifton13-Aug-09 5:54 
AnswerRe: GetRelativePath implementation ? Pin
Luc Pattyn13-Aug-09 6:52
sitebuilderLuc Pattyn13-Aug-09 6:52 
GeneralRe: GetRelativePath implementation ? Pin
Marc Clifton13-Aug-09 9:18
mvaMarc Clifton13-Aug-09 9:18 
GeneralRe: GetRelativePath implementation ? Pin
Luc Pattyn13-Aug-09 9:48
sitebuilderLuc Pattyn13-Aug-09 9:48 
GeneralRe: GetRelativePath implementation ? [modified] Pin
Scott Dorman13-Aug-09 10:36
professionalScott Dorman13-Aug-09 10:36 
GeneralRe: GetRelativePath implementation ? Pin
Luc Pattyn13-Aug-09 13:26
sitebuilderLuc Pattyn13-Aug-09 13:26 
GeneralRe: GetRelativePath implementation ? Pin
Scott Dorman13-Aug-09 13:48
professionalScott Dorman13-Aug-09 13:48 
AnswerRe: GetRelativePath implementation ? Pin
Scott Dorman13-Aug-09 13:50
professionalScott Dorman13-Aug-09 13:50 
QuestionButton Click event help Pin
spankyleo12313-Aug-09 4:51
spankyleo12313-Aug-09 4:51 
AnswerRe: Button Click event help Pin
stancrm13-Aug-09 4:55
stancrm13-Aug-09 4:55 
GeneralRe: Button Click event help Pin
spankyleo12313-Aug-09 5:15
spankyleo12313-Aug-09 5:15 

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.