|
Hi,
if you are logged in as a regular user and try to get information on a process that isn't yours, Windows will give you an "access denied" error (at least on Vista and 7, not sure for others). In general you have no rights on objects that don't belong to you.
BTW: An admin has no problems, Process.Exited does not need elevation.
|
|
|
|
|
Thanks Luc for your help but I already logged as "Computer Administrator"
(in Windows XP) but the same problem occurs all the time.
process.HasExited 'Access is Denied.
Is there any other way to check whether process has terminated or not, if yes then tell me.
Thanks.
Gagan
|
|
|
|
|
What process is it you want to check? Dit your app launch it?
Your code works fine for me checking my browser.
|
|
|
|
|
I am executing "cmd.exe" and getting its process id to check whether "cmd.exe" has terminated or not but all the time it gives the same "Access is Denied" error message.
|
|
|
|
|
Hi,
two suggestions:
1.
For processes that your app started, choose one of several Process.Start overloads that return a Process instance, so you don't need Process.GetProcessById()
2.
Rather than periodically checking Process.HasExited, you could have a thread (Thread, ThreadPool, BackgroundWorker) wait for its exit with Process.WaitForExit which also needs the process instance.
|
|
|
|
|
I have a table populated with details of people (Name, tel, address, etc.) Each record has a unique key. I want to fill a combobox with the names, but when a user clicks on the name I want to use the unique identifier to get the corresponding detail. Below is my code to fill the combobox. How should I change this so that the combobox also knows what the unique identifier is?
I am new to programming, so any other comments on my code would also be appreciated.
Thanks for any help.
Private Sub GetContactNames()
Dim SqlContactname As String _
= "SELECT _rtblPeople.idPeople, _rtblPeople.cDisplayName " _
& "FROM _rtblPeople, _rtblPeopleLinks " _
& "WHERE _rtblPeopleLinks.iDebtorID = @customercode " _
& "AND _rtblPeopleLinks.cModule = 'AR' " _
& "AND _rtblPeople.idPeople = _rtblPeopleLinks.iPeopleID"
Dim Sqlparam As SqlClient.SqlParameter
Sqlparam = New SqlClient.SqlParameter("@customercode", SqlDbType.Int)
Sqlparam.Value = My.Settings.CustomerCode
Using conn As New SqlConnection(CntString)
Try
conn.Open()
Dim MyCommand As New SqlCommand(SqlContactname, conn)
MyCommand.Parameters.Add(Sqlparam)
Dim datareader As SqlDataReader
datareader = MyCommand.ExecuteReader
While datareader.Read()
ContactNameField.Items.Add(datareader.Item("cDisplayName"))
End While
datareader.Close()
conn.Close()
Catch myerror As SqlException
MessageBox.Show("Error Connecting to Database: " & myerror.Message)
conn.Dispose()
End Try
End Using
End Sub
|
|
|
|
|
Hi,
you could create a little class describing an item in the combobox.
Then tell the ComboBox where the list of items is (DataSource), which property to use for displaying (DisplayMember) and which one for processing (ValueMember).
MSDN holds examples for all this.
|
|
|
|
|
OK, I think I managed to create the class and it seems to work, except when I have names in the combobox that are identical. Say I have values John(1), Paul(2), John(3). When I select the first John other fields on the form is refreshed using the correct value (1). When I select the second John it also works fine using the correct value (3). The problem is when I leave the comboxfield another SelectedIndexChange is fired and the value then changes to (1). When I select Paul I have no problem.
Here is the class I created - I copied the format from sample code:
Public Class myLookupClass
Private iID As Integer
Private sValue As String
Public Sub New(ByVal DisplayValue As String, ByVal ID As Integer)
iID = ID
sValue = DisplayValue
End Sub
Public Property GetLookup() As Integer
Get
Return iID
End Get
Set(ByVal value As Integer)
sValue = value
End Set
End Property
Public Overrides Function ToString() As String
'Return MyBase.ToString()
Return sValue
End Function
End Class
I populate the combobox like this
While datareader.Read()
ContactNameField.Items.Add( _
New myLookupClass((datareader.Item("cDisplayName")), _
(datareader.Item("idPeople"))))
End While
Any thoughts on were I am going wrong?
|
|
|
|
|
In some way, the names that you are showing (display values) should be unique. If there are going to be two or more the same, how will the user know which one he should pick?
In other words, if you solve that problem, you also won't have this problem.
My advice is free, and you may get what you paid for.
|
|
|
|
|
They would be unique most of the time, I am just trying to cover all possibilities. That is why I created the class to work with the ID of each field (which is unique). As the user selects a field, other fields on the form refresh to give them more info of the selected person so they will know who they selected even if the names are the same.
|
|
|
|
|
In that case you could use one of two workarounds:
1. The AchoiceWasMade boolean, to check whether the selected index was changed by the user. That way you circumvent the event firing twice.
or
2. Change the display value to include a number, for example the way you did in the original problem description: John (1) and John (2).
So you make the display value unique, and it would only make things clearer for the user.
My advice is free, and you may get what you paid for.
|
|
|
|
|
I like your first option - If I cant get it to work, i'll have to use the second option.
Thanks for the replies.
|
|
|
|
|
No problem.
P.S. The SelectedIndexChanged event may also fire when you start your application.
My advice is free, and you may get what you paid for.
|
|
|
|
|
I found a solution that works perfectly - instead of using SelectedIndexChange event, I used SelectionChangeCommitted event to trigger my refresh. So now it only refreshes when I actually click on a item in the combobox - which is exactly what i want.
|
|
|
|
|
Hello Every body,
I am trying to send data to server using post method. but this is showing "The Remote Server Returned an error :(411) Length Required". When i used get method to send data, then it is just send only 255 character.
i read that, using post method you can send unlimited data.
my data may be 255 character and i am sending data as a parameter like below.
Try
myUri = New Uri("https://www.mywebsite.com/apis/ConfirmContactUpdated.cfm?APIServiceTag=" & APIServiceTag.Trim & "&APISessionTag=" & AutheniticateSession & "&APIContactTag=" & myds.Tables(0).Rows(i)("tbl_All_Contact_List.ServiceTag").ToString.Trim & "&APIContactUpdatedBoolean=False" & "&APIContactUpdatedDateTime=" & myds.Tables(0).Rows(i)("tbl_All_Contact_List.LastUpdate").ToString.Trim & "&APIUpdateNotesBoolean=True&APINotesLastChangedDateTime=" & myds.Tables(0).Rows(i)("tbl_All_Contact_List.NotesLastUpdate").ToString.Trim & "&APINotesText=" & myds.Tables(0).Rows(i)("Updated_Note").ToString.Trim)
Dim reader As StreamReader
request = DirectCast(Net.WebRequest.Create(myUri), HttpWebRequest)
request.Method = "POST" '"GET"
request.ContentLength = myds.Tables(0).Rows(i)("Updated_Note").ToString.Trim.Length + 100
Try
response = DirectCast(request.GetResponse(), HttpWebResponse)
reader = New StreamReader(response.GetResponseStream())
Catch ex As System.Exception
MsgBox(ex.Message.ToString)
End Try
Can anybody send me example with source code so that i can check where i m wrong. Or plese review this code.
I am using vb.net 2005.
Thakns in advancd.
Regards
DC
|
|
|
|
|
May be for you can be interesting to read this:
http://www.checkupdown.com/status/E411.html
|
|
|
|
|
hello,
First of all thanks for reply...
I have solve this problem and solution is
Dim oWeb As New System.Net.WebClient()
oWeb.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
Try
Dim bytRetData As Byte() = oWeb.UploadData(myUri, "POST", requestBytes)
Catch ex As System.Exception
MsgBox(ex.Message.ToString)
Finally
oWeb.Dispose()
End Try
Regards
DC
|
|
|
|
|
OK, I have multiple controls hidden on my form. I want to show them, based on the combo box selection. In other words if the user selects SelectedIndex 0, then I want to show the first row of controls, SelectedIndex 1, the first row and the second row of controls. I'm having trouble doing this in an efficient manner. I know I can just bludgeon the code into doing this by just typing my code over and over again, but I feel this can be achieved more efficiently and I'm looking for help. I'm new to programming and I'm trying to learn by building my own project. Thank you, here is an example of the code I have so far...
'Show the rows selected based on the number chosen by the user
Select Case CInt(cboFundSelector.SelectedIndex)
Case 0
lblUnits.Visible = True
lblPrice.Visible = True
txtNameofFund1.Visible = True
txtUnits1.Visible = True
txtPrice1.Visible = True
lblFund1Total.Visible = True
Case 1
lblUnits.Visible = True
lblPrice.Visible = True
txtNameofFund1.Visible = True
txtUnits1.Visible = True
txtPrice1.Visible = True
lblFund1Total.Visible = True
txtNameofFund2.Visible = True
txtUnits2.Visible = True
txtPrice2.Visible = True
lblFund2Total.Visible = True
|
|
|
|
|
Your best bet is to do this with a loop. Create some sort of template for rows of data, such as a gridview. Then once you know how many rows to show, iterate over that number of rows and make them visible.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Their are several ways to do this
1)
Use the Tag Property of the controls let's suppose Put "1" in controls where your case is 1
and put the following code
For Each Control As System.Windows.Forms.Control In Me.Controls
If TypeOf Control Is TextBox Then
If Control.Tag = "1" Then
Control.Visible = False
End If
End If
Next
2).
You can also use the GroupBox Control and can set its visibility to true and False if your controls are in one order/Sequence rather then doing whole controls
Best Of Regards,
SOFTDEV
Sad like books with torn pages, sad like unfinished stories ...
|
|
|
|
|
A better way would be to group the controls in different panels and toggle the visibility of panel according to the selection.
|
|
|
|
|
write a windows application that allows the user to enter
a seven-digit number in a multiple line textbox
when the user clicks the generate words button.I changed as much code I have yesterday but it is not generating words can anyone help me
[code]
Partial Class Form1
Inherits System.Windows.Forms.Form
Public Numbers(7, 3) As String
Public Phonenumber As Integer
Public output As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Numbers(0, 0) = "A"
Numbers(0, 1) = "B" '2
Numbers(0, 2) = "C" '2
Numbers(1, 0) = "D" '3
Numbers(1, 1) = "E" '3
Numbers(1, 2) = "F" '3
Numbers(2, 0) = "G" '4
Numbers(2, 1) = "H" '4
Numbers(2, 2) = "I" '4
Numbers(3, 0) = "J" '5
Numbers(3, 1) = "K" '5
Numbers(3, 2) = "L" '5
Numbers(4, 0) = "M" '6
Numbers(4, 1) = "N" '6
Numbers(4, 2) = "O" '6
Numbers(5, 0) = "P" '7
Numbers(5, 1) = "R" '7
Numbers(5, 2) = "S" '7
Numbers(6, 0) = "T" '8
Numbers(6, 1) = "U" '8
Numbers(6, 2) = "V" '8
Numbers(7, 0) = "W" '9
Numbers(7, 1) = "X" '9
Numbers(7, 2) = "Y" '9
End Sub
Private Sub GenerateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GenerateButton.Click
Dim phoneNumber As String = GetNumber()
'check if the number contains 0 or 1
While phoneNumber.Contains("0") Or phoneNumber.Contains("1")
phoneNumber = GetNumber()
End While
'create a hashtable to hold the digits
Dim arrayL As New Hashtable
Dim x As Integer = 1
For i As Integer = 65 To 90 Step 3
arrayL.Add(x, New Char() {Chr(i), Chr(i + 1), Chr(i + 2)})
x += 1
Next
Dim word As String = ""
'creates only 3 words out of the phonenumber
For i As Integer = 0 To 2
For Each s As String In phoneNumber
word = word & DirectCast(arrayL.Item(CInt(s)), Char())(i).ToString
Next
Next
output = PhoneNumberWordsListBox.Text
End Sub
Private Sub PhoneNumberTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PhoneNumberTextBox.TextChanged
Phonenumber = PhoneNumberTextBox.Text
End Sub
Private Function GetNumber() As String
Return PhoneNumberTextBox.Text()
End Function
End Class
[/code]
|
|
|
|
|
Please confirm that what you want to do is:
User types "123" into textbox (but 7 digits not 3)
Clicks button
Output is "one two three"
Is that correct?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I have to generate a telephone number word not to spell the number
ex: 4247288 = HAIRCUT
|
|
|
|
|
That was not clear in any of your posts about this. If you had given that example you might have got some help.
BTW when posting code surround it with <pre>your code goes here</pre> tags, we don't use [code][/code] on CP.
Now that your problem is clear, I will have to think about it. If I get any ideas I will post back to you. In the mean time others might have suggestions.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|