• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 165
  • Last Modified:

Querying database for nodeid, uploading file to folder based on nodeid

My brain is about to explode from working on this most of the week, I am tired so I will ask the experts, lol.  

I am building a VB 2005 - .NET app that has datagridviews to list Regions, Districts, Stores, States, etc.  The easy way to explain this, is that the user selects these individual or multiple references from the gridviews and then uploads a file to a folder \\fileserver6\marketing\etc.  But the catch here is that the nodes might change in the future, so I need to upload to the folders based on querying the node name.  Another problem I am running into is this, I am populating the data fine in the datagridviews, but it would be nice if I knew how to fix it to where if they select something or multiple things from the datagridview it would carry over and when they browse for the file to upload, it would automatically know where to put it.

The only thing that needs to be added to the database is a filealias box in case they need to change the file name.  And linking the text boxes to the upload button has been a headache too.  Any and all help is appreciated.
0
edfreels
Asked:
edfreels
  • 23
  • 18
1 Solution
 
Bob LearnedCommented:
This is a pretty broad question.  What would you like help with?

Bob
0
 
edfreelsAuthor Commented:
lol bob,

I would settle for being able to click the datagridview items either once or select multiple items from the datagridview and put a text box out to the side with a file upload dialog.  Whatever the use selected out of the datagridview would automatically query the node it and know where to put the files that they are uploading, hows that?

0
 
Bob LearnedCommented:
You could define a DataGridViewLinkColumn, and when you click on the link, a value could be set on a TextBox.  Does that sound like something that you want to do?

Bob
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
edfreelsAuthor Commented:
Yes that sounds very close, but when it goes into the text box, it would have to know the nodeid of the database as well.  So when the user selected the files to upload, it would automatically know which folder on the intranet to upload them to.
0
 
Bob LearnedCommented:
If you have a Link column, with the text for the hyperlink, then you could have the NodeID in a different column that you could get the value for.

Bob
0
 
edfreelsAuthor Commented:
where would the link be.  I have the datagridview and have looked through the properties but do not see it.  I have it setup where you see the nodeid , but the end user will not see it.  So how will I go about passing that over.
0
 
Bob LearnedCommented:
One way is to set the Text and UseColumnTextForLinkValue.

Example:
    Me.Column1.HeaderText = "Column1"
    Me.Column1.LinkBehavior = System.Windows.Forms.LinkBehavior.AlwaysUnderline
    Me.Column1.Name = "Column1"
    Me.Column1.Text = "http://www.google.com"
    Me.Column1.UseColumnTextForLinkValue = True

Otherwise, you need to bind the DataGridView, and set the DataPropertyName to a column where you get the link text from.

Bob
0
 
edfreelsAuthor Commented:
Sorry for the late response learned, but I still cannot get it to work.  I now have a text box that is bound to the stored procedure "GetAllStates"  Which lists all states in our area, 7 of em.  Now, I need to be able to click one or multiple states and have it automatically query the database for the nodeid.  That is not so much my problem as getting a filedialog box to open so the user can actually upload the files from their local PC.  I am fairly new to VB2005 and the .NET environment, so treat me like a moron here, lol.  What is the process for getting a browse box to open and when the user finds their files, those go into a text box for upload?
0
 
Bob LearnedCommented:
Hmmm, I never got the notification for this one.

Are you displaying each state in a row of a text column?

Bob
0
 
edfreelsAuthor Commented:
Hey Bob,

This is kind of the same question I am asking on the other one.  With the datagridview, but if it is not doable that way, I can listbox it too, it still will be connected to the database.
0
 
edfreelsAuthor Commented:
close please, no one is going to answer
0
 
Bob LearnedCommented:
You have to give me an idea of what you trying to get the DataGridView to look like, and then I can come up with something.  Otherwise, I am taking a shot in the dark, and wasting my time.

Bob
0
 
edfreelsAuthor Commented:
Ok stay with me on this one Bob, I am almost finished.  I need two things.  The first thing is this.  When the form loads I have a datagridview that just pops up and lists the stores in the company.  I want the user to be able to click the store, or multiple stores, they want in the datagridview and it will automatically either make a call to the nodeid or query the nodeid and keep it in memory.  Now you helped me setup the openfiledialog yesterday.  That is right beside the datagridview.  When the user selects their store from the datagridview, then selects the pdfs they want to upload, then hits an upload button that collects those files and puts them on the intranet.

Long story short, the folders on the intranet are setup by store.  The database, sql, knows by the nodeid which folder to put them in.  

So I also need a piece of code that will allow that upload to gather the files out of the box and put them in that intranet folder.  Here is the code you helped me with yesterday

    Dim MyDialog As New OpenFileDialog()
        MyDialog.InitialDirectory = False
        MyDialog.ShowHelp = True
        MyDialog.ShowReadOnly = False
        MyDialog.Multiselect = True
        If MyDialog.ShowDialog() = DialogResult.OK Then
            For Each fileName As String In MyDialog.FileNames
                Me.TextBox4.AppendText(fileName & vbCrLf)
            Next
        End If

Ok, now I need a command button that will upload those files to this path "\\fileserver1\intranet\marketingpromotion\st<nodeid>"
0
 
Bob LearnedCommented:
You know a picture is worth 1000 words.

Can you come up with something, like a screen shot or use Excel to show me what you mean?

Upload to here:
http://www.ee-stuff.com

Bob
0
 
edfreelsAuthor Commented:
Couldn't get it uploaded to the ee-stuff.com, it would not find my question, so I put it here.  You will see in the picture the stores and they should be able to select one or multiple and it would upload the files based on the nodeids.  

http://i143.photobucket.com/albums/r125/jason490/pictureofproject2.jpg
0
 
Bob LearnedCommented:
Perfect!!

Questions:

1) Are you trying to work with the DataGridView or the Upload TextBox?

2) Do you need to add states to the DataGridView?  I see where AllowUsersToAddRows = True.

Bob
0
 
edfreelsAuthor Commented:
1)  Well here is the filepath where the files are going \\fileserver1\intranet\marketing\st<nodeid>
  The nodeid part is what needs to be populated from the datagridview.  Then based on that info that it gets when the user selects a state or states, it knows what folder to put it in.  Might be st123 or st123 and st456.  Hope that makes sense.

2)  No no need to do anything to the datagridviews, they are really just there to show the user what states, stores, etc there are in the company.  I will uncheck the add, edit, etc. at the final project, they are just there to show me the nodeids for now.
0
 
Bob LearnedCommented:
Is 'nodeid' a hidden column in the DataGridView?

Bob
0
 
edfreelsAuthor Commented:
Thats a good question.  It does not need to be if I can still pull that data in.  Whichever way, the datagridview is there for the selection for the user.  

The nodeid shows up in the design view but not in the final project when I run debug.  So I guess the answer is yes, it is hidden.
0
 
Bob LearnedCommented:
You can always get values from another column in the DataGridView, even if the column is hidden (Visible = False):

Dim row As DataGridViewRow = Me.dgv.CurrentRow
Dim cell As DataGridViewCell = row.Cells(Me.columnNodeId.Index)
Dim nodeID As String = cell.Value.ToString()

'columnNodeId' is the name of the column specified through the designer.

Bob
0
 
edfreelsAuthor Commented:
Ok I follow you, but how do I tie that into my project
0
 
Bob LearnedCommented:
That all depends on what action that you want to drive this.  

Bob
0
 
edfreelsAuthor Commented:
Well if easier, I can use a listbox and tie the database into that and they can select it, or the datagrid view.  I think the best way is if they select the state then that gets the nodeid automatically.  Then they select their files from the box you helped me with.  Then I need an upload command button that will upload the files that are listed in that textbox.  I still need the code for that too.  I just am not sure how to tie it all together.

Thanks
0
 
Bob LearnedCommented:
If you use a ListBox, then you can have a DisplayMember for display and a ValueMember for the nodeid.

Here is an example of data binding a ListBox to a DataTable with the Path and ID columns:

Me.ListBox1.DataSource = Me.DataSet1.Tables(0)
Me.ListBox1.DisplayMember = "Path"
Me.ListBox1.ValueMember = "ID"

Bob
0
 
edfreelsAuthor Commented:
Ok, I used the listbox task and binded  like this

Checked "use data bound items"
Data Source = GetAllStatesBindingSource
Display Member = State

So do I still need the above code you posted, or do I need to do something else now to get that query when they choose the state?
0
 
Bob LearnedCommented:
Did you set the ValueMember?

Bob
0
 
edfreelsAuthor Commented:
no, not sure what to set it to?
0
 
edfreelsAuthor Commented:
well value member is set to state, selected value is set to none
0
 
edfreelsAuthor Commented:
did you get tired of me bob? lol
0
 
Bob LearnedCommented:
Dude, you must expect that I don't have things to do for myself!!

Does GetAllStatesBindingSource have the 'nodeid'?

Bob
0
 
edfreelsAuthor Commented:
Sorry Bob,

I don't expect that, this has just been a headache.  Ok I just talked to our sql person.  The GetAllStates is just there to list the states.  On the page I showed you it was lacking a part.  When they select a state then there is another query called GetAllStateStores.  That is where the NodeId is.  So I have another picture for you to see here,

http://i143.photobucket.com/albums/r125/jason490/newproject3.jpg

As you can see when it list the states, I did a fillby method so that they can select the states and then it list the stores by state.  When they select the stores then that is where I need it to know what nodeid the store is.  Sorry for the confusion.  I will mail you a bottle of crown royal if we can get this to work, lol.
0
 
Bob LearnedCommented:
So, now you need to call another stored procedure to get the 'nodeid' value for a selected state.  What are the arguments for the stored procedure?  How is the data returned?

Bob
0
 
edfreelsAuthor Commented:
The argument is just like 'AL' for Alabama if that was the state.  The sql person says that you pass the AL to the stored procedure GetAllStateStores and what comes back in that, the stores by state, has the nodeid.   Hope that makes sense.
0
 
Bob LearnedCommented:
So, something like this:

Public Function GetNodeID(ByVal state As String)

Using connection As New SqlConnection("connection string goes here")
    connection.Open()
    Using command As New SqlCommand("GetAllStatesStores")
        command.CommandType = CommandType.StoredProcedure
        command.Parameters.AddWithValue("@State", state)
        return command.ExecuteScalar()
    End Using
End Using

End Function

Bob
0
 
edfreelsAuthor Commented:
Thanks a TON bob,

I will try that out first thing Thursday morning and let you know how it goes.  Just don't forget the thread, I don't wanna let you go just yet, lol.
0
 
edfreelsAuthor Commented:
Bob,

What would I need to type to call this function in the listbox code?
0
 
edfreelsAuthor Commented:
Ok, I added this to the listbox

ListBox1.Text = GetNodeID()

It says argument not specified for parameter 'state' of Public Function

?
0
 
Bob LearnedCommented:
Ah, another never-ending question ;)

At the top of the ListBox, I see a state "GA".  That is the value that I think you need to specify in the GetNodeID function call.  I just don't know what kind of control that is.  It looks like a ToolStrip at the top of the ListBox.

Bob

0
 
edfreelsAuthor Commented:
yea it is, they fill the state they want in that box and click fill and it populates the stores in that list box.  Do I need to do something different there?

lol, I promise you will be rid of me when I finish this, lol. ;-P
0
 
Bob LearnedCommented:
All you need to know is what state your are going to pass to the GetNodeId function.  It is really up to you to determine that.  I took a guess, but I could be wrong.

Bob
0
 
edfreelsAuthor Commented:
Thanks Bob
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 23
  • 18
Tackle projects and never again get stuck behind a technical roadblock.
Join Now