12 Replies - 1378 Views - Last Post: 04 December 2010 - 03:05 PM Rate Topic: -----

#1 Sparukus   User is offline

  • D.I.C Head

Reputation: -11
  • View blog
  • Posts: 190
  • Joined: 05-April 10

how to extract from database

Posted 04 December 2010 - 05:59 AM

hey looking for code to extract from sql database, need to find the photoPath colum and extract the pathname then some how swing it round to do a ftp delete.

Just not sure how to extract the photopath and some how store it?

This post has been edited by Sparukus: 04 December 2010 - 10:34 AM

Is This A Good Question/Topic? -2
  • +

Replies To: how to extract from database

#2 Sergio Tapia   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1258
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: how to extract from database

Posted 04 December 2010 - 06:00 AM

You've asked a lot of question here before man, you know the rules.
Was This Post Helpful? 1
  • +
  • -

#3 Sparukus   User is offline

  • D.I.C Head

Reputation: -11
  • View blog
  • Posts: 190
  • Joined: 05-April 10

Re: how to extract from database

Posted 04 December 2010 - 06:09 AM

.

This post has been edited by Sparukus: 04 December 2010 - 10:43 AM

Was This Post Helpful? -1
  • +
  • -

#4 Sergio Tapia   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1258
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: how to extract from database

Posted 04 December 2010 - 06:22 AM

When it doubt, break it down. What do you need to accomplish first? I mean something tiny tiny tiny that's manageable? Divide and conquer.
Was This Post Helpful? 0
  • +
  • -

#5 Sparukus   User is offline

  • D.I.C Head

Reputation: -11
  • View blog
  • Posts: 190
  • Joined: 05-April 10

Re: how to extract from database

Posted 04 December 2010 - 07:48 AM

.

This post has been edited by Sparukus: 04 December 2010 - 10:34 AM

Was This Post Helpful? 0
  • +
  • -

#6 Sparukus   User is offline

  • D.I.C Head

Reputation: -11
  • View blog
  • Posts: 190
  • Joined: 05-April 10

Re: how to extract from database

Posted 04 December 2010 - 08:06 AM

Hey im trying to store a string from a selected item in a datagrid as it has a filepath id like to use to delete.

Not sure im going about it the right way.

my colums look like this

| ID | UserNumber | FirstName | LastName | Current | imagePath |
01 454656 Harry Potter Wizard ftp://192.168.1.8/Jellyfish.jpg

im trying to "on selection" in my datagrid when i delete i also delete from my ftp server

 private void button2_Click(object sender, RoutedEventArgs e)
        {

            string imagePath = dataGrid1.SelectedItems[6].ToString();
            Stu selected = dataGrid1.SelectedItem as Stu;
            if (selected == null)
                MessageBox.Show("You must select a user");

            else
            {
                if(MessageBoxResult.Yes == MessageBox.Show("Are you sure", "delete user",
                    MessageBoxButton.YesNo, MessageBoxImage.Warning))
                {
                    FTPdelete(imagePath, "Administrator", "commando");
                    Class1.DeleteStu(selected);
                    Window_Loaded(null, null);
 
                }
            }
            
           
            
        }

        private void FTPdelete(String imagePath, String inUsername, String inPassword)
        {
            var req = (FtpWebRequest)WebRequest.Create(imagePath);
            req.Proxy = null;
            req.Credentials = new NetworkCredential(inUsername, inPassword);

            req.Method = WebRequestMethods.Ftp.DeleteFile;

            req.GetResponse().Close();  
        }

    }
}



the error i get:

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

on this line:

string imagePath = dataGrid1.SelectedItems[6].ToString();


Ive also tryed

var imagePath = dataGrid1.SelectedItems[6].ToString();


No luck :( Thought I almost had it!!
Was This Post Helpful? 0
  • +
  • -

#7 JackOfAllTrades   User is offline

  • Saucy!
  • member icon

Reputation: 6259
  • View blog
  • Posts: 24,028
  • Joined: 23-August 08

Re: how to extract from database

Posted 04 December 2010 - 08:09 AM

This is just a continuation of your previous topic.

Merged duplicate topics.
Was This Post Helpful? 1
  • +
  • -

#8 Sparukus   User is offline

  • D.I.C Head

Reputation: -11
  • View blog
  • Posts: 190
  • Joined: 05-April 10

Re: how to extract from database

Posted 04 December 2010 - 08:38 AM

.

This post has been edited by Sparukus: 04 December 2010 - 10:34 AM

Was This Post Helpful? 0
  • +
  • -

#9 Sergio Tapia   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1258
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: how to extract from database

Posted 04 December 2010 - 08:54 AM

SelectedItems is a collection. It has the selected items in your GridView. I imagine you are only selecting a single item, and trying to access item 6 in that collection. But whaaaat SelectedItems will only have 1 single item. Not 7.

Think about it. Also, indexes start on 0. *hint hint*
Was This Post Helpful? 0
  • +
  • -

#10 Sparukus   User is offline

  • D.I.C Head

Reputation: -11
  • View blog
  • Posts: 190
  • Joined: 05-April 10

Re: how to extract from database

Posted 04 December 2010 - 09:00 AM

.

This post has been edited by Sparukus: 04 December 2010 - 10:33 AM

Was This Post Helpful? 0
  • +
  • -

#11 Sergio Tapia   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1258
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: how to extract from database

Posted 04 December 2010 - 09:03 AM

If you're not going to bother reading and trying to comprehend why would anyone waste their time helping you? You've been a member here for quite some time, I'd imagine you are familiar with the general flow DIC has.

I'm not going to help you unless you prove that you are trying. I feel like you're just cobbling code together and pressing F5 until the little blinky red lights disappear.
Was This Post Helpful? 0
  • +
  • -

#12 Sparukus   User is offline

  • D.I.C Head

Reputation: -11
  • View blog
  • Posts: 190
  • Joined: 05-April 10

Re: how to extract from database

Posted 04 December 2010 - 09:09 AM

This is impossible

This post has been edited by Sparukus: 04 December 2010 - 10:44 AM

Was This Post Helpful? 0
  • +
  • -

#13 Sparukus   User is offline

  • D.I.C Head

Reputation: -11
  • View blog
  • Posts: 190
  • Joined: 05-April 10

Re: how to extract from database

Posted 04 December 2010 - 03:05 PM

Ok got it, probably a better way altho the indexing does start at 0 (boo) even changing it to 5 still gave the error.

For any one who wants to know how to grab a coloum from a datagrid bound to a sqldatasource:

Stu selected = dataGrid1.SelectedItem as Stu;
var imagePath = selected.ImagePath;



ImagePath being the name of my coloum and of my database coloum.

I was then able to use imagePath else where :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1