[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Passing nodeid to upload command button

Posted on 2007-08-03
Medium Priority
Last Modified: 2010-04-23
Hey All,

I have a listbox that generates state stores.  When the user clicks on the stores it gets the nodeid by this code.

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Dim connectionString As String = _
"Data Source=WHSQL2K301;Initial Catalog=WilcoIntranet;Persist Security Info=True;User ID=coldfusion;Password=coldfusion"

Dim cn As New SqlClient.SqlConnection(connectionString)
Dim da As New SqlClient.SqlDataAdapter()
da.SelectCommand = New SqlClient.SqlCommand()
With da.SelectCommand
.Connection = cn
.CommandType = CommandType.Text

'You need to change the CommandText Select Statement
' Change "NodeID" to the nodeID column name
' Change "StoreName " to the nodeID column name
' Change "StoresTable " to the name of the table in your database
.CommandText = _
"SELECT NodeID, NodeNbr FROM Node ORDER BY NodeName"
End With

Me.ListBox1.DisplayMember = "NodeName"
Me.ListBox1.ValueMember = "NodeID"
End Sub

This is the problem Dim destinationFolder As String = "\\fileserver1\wilcointranet\marketingpromotion\st<nodeid>"

I need something there that will put a wildcard in the st<nodeid> so it will know what nodeid to go to from the listbox we made. If I put it in above it says "illegal characters" because of the <nodeid>

Here is that code.

Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
Dim destinationFolder As String = "\\fileserver1\wilcointranet\marketingpromotion\"

Dim files As String() = Me.TextBox5.Text.Split(vbCrLf)
For Each file As String In files
'Remove unwanted character
file = file.Replace(Chr(10), "")

If file.Trim() <> "" Then
'copy file
My.Computer.FileSystem.CopyFile(file, _
IO.Path.Combine(destinationFolder, IO.Path.GetFileName(file)), _
End If

End Sub

Question by:edfreels
LVL 16

Accepted Solution

TSmooth earned 2000 total points
ID: 19624289
Try this:

Dim destinationFolder As String = String.Format("\\fileserver1\wilcointranet\marketingpromotion\{0}", ListBox1.SelectedValue)

Author Comment

ID: 19624320
YOU ARE THE BEST!!!! Worked like a charm man, thanks a TON.

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question