|
I am trying to use linq...however running into the issue...
how to I combine 3 fileds to Date?
.Dates = rows.Select(Function(r) r.Field(Of DateTime?)("DEIBMT") & "/" & ("DEIBDY") & "/" & ("DEIBCY") & ("DEIBYR"))
Dim data = myDataTable.AsEnumerable().GroupBy(Function(r) New With {Key .EEGRP = r.Field(Of String)("EEGRP"), Key .EESSN = r.Field(Of String)("EESSN")},
Function(key, rows) New With
{
Key .EEGRP = key.EEGRP,
Key .EESSN = key.EESSN,
.Dates = rows.Select(Function(r) _
r.Field(Of String)("DEIBMT")) _
.OrderByDescending(Function(d) d).Take(3).ToList()}
)
|
|
|
|
|
It depends what type your columns are. Assuming integers, something like this should work:
.Dates = rows.Select(Function(r) New DateTime( _
(100 * r.Field(Of Integer)("DEIBCY")) + r.Field(Of Integer)("DEIBYR"), _
r.Field(Of Integer)("DEIBMT"), _
r.Field(Of Integer)("DEIBDY")))
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
All columns string... could you show me how I should do this with strings?
|
|
|
|
|
String representations of integers, or something else?
If it's integers, then Integer.TryParse will work:
Private Shared Function DateFromStringParts(ByVal century As String, ByVal year As String, ByVal month As String, ByVal day As String) As DateTime?
Dim cy, yr, mt, dy As Integer
If Not Integer.TryParse(century, cy) Then Return Nothing
If Not Integer.TryParse(year, yr) Then Return Nothing
If Not Integer.TryParse(month, mt) Then Return Nothing
If Not Integer.TryParse(day, dy) Then Return Nothing
Return New DateTime((100 * cy) + yr, mt, dy)
End Function
...
.Dates = rows.Select(Function(r) DateFromStringParts( _
r.Field(Of String)("DEIBCY"), _
r.Field(Of String)("DEIBYR"), _
r.Field(Of String)("DEIBMT"), _
r.Field(Of String)("DEIBDY")))
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
nice !!
|
|
|
|
|
I have a ListView control inside my system where its content display different information based on different Button control. And information will only be displayed if the user have the right to view the information. This is filtered when they login into the system. So for example, the user is a student and he can only view information from Button1.Text, Button2.Text, Button5.Text and the rest button will result blank in ListView1.Text (because as I mentioned, they have no right to view certain information). So I want those button that isn't showing any information to become invisible.
The code that I currently use
If ListView1.Items.Count > 0 Then
For Each controls As Control In Panel1.Controls
If TypeOf controls Is Button Then
DirectCast(controls, Button).Visible = False
End If
Next
End If
But if I use this code, the whole Button will become invisible because all Buttons refer to the same ListView control. So how would I code it to make the ListView1.Text be able to recognize which Button it belonged to and make them invisible?
|
|
|
|
|
You should make this decision when the user logs on. Based on the status you just show the buttons that are relevant to that user. They can then click any that are visible to get the ListView populated.
|
|
|
|
|
Hello guys, I have created a simple VB.net program (windows form application) and everything is working fine. But I want my program be able to copy itself to the desktop when user launch it for the first time. And this copying process should be done silently without showing to user. How to do that? Thank you.
|
|
|
|
|
Where do you intend to copy the .exe FROM?
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Elly08 wrote: And this copying process should be done silently without showing to user. Why? You should not be modifying the user's setup without their permission.
|
|
|
|
|
First, copying the .EXE and .DLL files you the users Desktop is a REALLY STUPID IDEA!
You INSTALL your application into a proper folder, like some folder under Program Files. You then create a shortcut to the application on the All Users Desktop or the users Desktop. This is also usually done from your installation .MSI.
Copying the application files to the Desktop gives every opportunity to the user to screw up the application since they will have full permissions to modify anything and everything on the Desktop, deleting your application files, any supporting .DLL's and configuration files, ..., what have you.
Besides, copying the files to the desktop cannot be done "silently". SUre, you can do it without showing a progress bar, BUT THE FILES WILL STILL SHOW UP ON THE DESKTOP!
|
|
|
|
|
I suspect he want to do this from a web browser
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
So do I. That's an even dumber idea and an even greater security risk.
|
|
|
|
|
Sorry, my question might not clear. What I mean here is, how do I copy the package file (not the source code) to user PC when they launch the program. I want the program will be able to copy its file from the release folder (inside the bin folder) to the temporary folder.
|
|
|
|
|
Still not clear at all.
What kind of app is this? ASP.NET, Windows Forms, WPF, ...??
How is the user launching this if it's not already on their machine?
|
|
|
|
|
My program is a Windows Form App. The .exe shortcut is inside the server so only user that connecting to the network can access it. So when the user launch it for the first time, the file from release folder will be copied to user pc in C:\Temp, if no such folder then it will be created automatically.
|
|
|
|
|
OK, that makes a bit more sense.
But, C:\Temp is not writable by everyone and not everyone will be able to create the folder unless your corporate powers-that-be have allowed that to happen.
A better alternative is C:\Users\userName\App Data\Local\Temp. This folder always exists and the user can write to it by default. The path to the Local folder can be had by calling Environment.GetFolderPath(SpecialFolder.LocalApplicationData). After that, you can append the Temp folder to the path using Path.Combine().
WARNING. Code running from a non-local source, i.e. a network share, runs in a VERY restricted sandbox and may not be able to do what you want.
On top of that, the .EXE file is LOCKED when it's running. You cannot open it to make a copy while the code is running and you cannot overwrite the .EXE if you're running the local copy of the .EXE and looking to update it from the network source.
The real question is WHY you want to do this? It serves no real purpose.
|
|
|
|
|
As I know, if user directly access the program from server, the app will load too slow. So by copying the file to local it will load more faster because everytime user launch the program, it will load the one inside the local file.
|
|
|
|
|
ClickOnce[^] might work, but it can be a bit flaky.
Alternatively, try Squirrel[^] - "It's like ClickOnce but Works™". Gregor Suttie has a walkthrough on his blog[^] which should get you started.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Yeah, this is not a solution for that. You create an installer and install the app on the workstation to solve this problem. You do this either using traditional methods or ClickOnce or, as mentioned, Squirrel.
|
|
|
|
|
Would this suffice:
Creating a shortcut to that .exe, and copying that shortcut to the Desktop. All done programmatically.
|
|
|
|
|
Yeah, but that doesn't solve the problem of a long launch time when launched from a network location.
His only reasonable solution to that is to install the app locally.
|
|
|
|
|
Please let me know how to resolve the above issue
Thanks in advance
|
|
|
|
|
What does that mean? And what does it have to do with Visual Basic?
|
|
|
|
|
Hi,
I found this code on the internet. but now I want to know of a member is a group or a normal login. Someone has an idee how to find this info?
Jan
Set cmd = CreateObject("ADODB.Command")
Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
cn.Open "Provider=ADsDSOObject;"
cmd.CommandText = "SELECT adspath,cn from 'LDAP://" & getNC & _
"' WHERE objectCategory = 'Group' and cn = '" & groupname & "'"
cmd.activeconnection = cn
Set rs = cmd.Execute
'
'**
' process the results of the query into our arrays for later
'**
'
i = 0
While rs.EOF <> True And rs.bof <> True
grouppaths(i) = rs.fields("adspath").Value
groupnames(i) = rs.fields("cn").Value
rs.movenext
i = i + 1
Wend
cn.Close
If i = 0 Then
MsgBox "Nothing Found, Exiting"
Exit Sub
End If
Application.StatusBar = "Records Found..." & i
'
'**
' Turn off updates and calculations
'**
'
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.DisplayStatusBar = True
'
'**
' found something so create the output files and write the headers
'**
'
Application.StatusBar = "Creating Worksheet headers..."
If i > 0 Then
Set objsheet = Worksheets(blad)
For h = 1 To 2 '1 To numheader2
objsheet.Cells(1, h) = headers2(h)
objsheet.Cells(1, h).Font.Bold = True
Next
End If
'
'**
' now process each group found and extract all members
'**
'
cl = 1 'count lines
gl = 1 'group lines
Application.StatusBar = "Populating Worksheets..."
For j = 0 To i - 1
Application.StatusBar = "Writing Group " & j & " of " & i
Set objgroup = GetObject(grouppaths(j))
cl = cl + 1
groupname.Offset(, 1) = objgroup.Members.Count
c = objgroup.Members.Count
g = 0
Set objsheet = Worksheets(blad)
If objgroup.Members.Count > 0 Then
For Each objmember In objgroup.Members
g = g + 1
Application.StatusBar = "Writing Group Details " & g & " of " & c
gl = gl + 1
objsheet.Cells(gl, 1).Value = groupnames(j)
objsheet.Cells(gl, 2).Value = Right(objmember.name, Len(objmember.name) - 3)
objsheet.Cells(gl, 3).Value = objmember.OperatingSystem
objsheet.Cells(gl, 4).Value = objmember.distinguishedName
Next
Else
gl = gl + 1
objsheet.Cells(gl, 1).Value = groupnames(j)
For h = 2 To 2 'numheader2
objsheet.Cells(gl, h) = NoEntry
Next
End If
Next
|
|
|
|