|
Never mind....found the answer
Dim articleID As SqlParameter = myCmd.Parameters.AddWithValue("@articleID", Row.Cells("DataGridViewTextBoxColumn1").Value) 'Me.Article_searchDataGridView.CurrentRow.Index).Value)<br />
articleID.Direction = ParameterDirection.Input
|
|
|
|
|
Hello !
I selected a dropdownlist from tool bar to my project. I am doing a web page with VB.NET. How do I get my dropdownlist item selected doing something without a button? I want, when I click an item in dropdownlist, it should open a new web page. Now all the action needs button.
|
|
|
|
|
I'm not sure what you're asking. Have you tried the SelectedIndexChanged event or the ComboBox.Select method?
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
Hi,
set "Autopostback" property to true.
Sherin Iranimose
|
|
|
|
|
Thanks, "Autopostback" really helps !
|
|
|
|
|
In the application I'm currently working on the users don't have admin rights on the network but one of the requirements for the application is for the application to search the Active Directory to ensure the login name provided is valid before adding a new agent. If the searching user needs admin rights, and the users performing this process dont have admin rights, how can I get this to work for them, as it is essential?
"Okay, I give up: which is NOT a real programming language????"
Michael Bergman
"Well yes, it is an Integer, but it's a metrosexual Integer. For all we know, under all that hair gel it could be a Boolean."
Tom Welch
"Let's face it, the average computer user has the brain of a Spider Monkey."
Bill Gates
|
|
|
|
|
RLMcCutchen wrote: If the searching user needs admin rights, and the users performing this process dont have admin rights, how can I get this to work for them, as it is essential?
If all you're doing is looking up a user in the directory, you shouldn't need admin rights to do it. If you're creating new users in the directory, that's something totally different. The user will most likely need to have the appropriate rights to create the User object in the target container.
If you're absolutely sure the user is going to need admin rights, they are going to have to have admin rights. You simply can't get around this in your code since all code the user launches is running under their security context, and all the limitations it imposes.
|
|
|
|
|
Dave,
Thanks for your reply. The managers performing this process wont be creating new users in the AD, just in the database (the user is added to the AD via the network admins) so now I know I have no problems. The application simply needs to search the AD to ensure the login they're adding to the database exists for that new agent.
"Okay, I give up: which is NOT a real programming language????"
Michael Bergman
"Well yes, it is an Integer, but it's a metrosexual Integer. For all we know, under all that hair gel it could be a Boolean."
Tom Welch
"Let's face it, the average computer user has the brain of a Spider Monkey."
Bill Gates
|
|
|
|
|
Yeah, so long as all you're doing is searching to see if the username exists already, there shouldn't be any issues. That is, of course, unless the Admin's changed the default permissions of the User's doing the searching!
|
|
|
|
|
Ok now Im frustrated
I haver this function to search the AD
Public Shared Function IsValidADLogin(ByVal loginName As String, ByVal givenName As String) As fnStatRtn
Dim oReturn As New fnStatRtn(True)
Dim search As New DirectorySearcher()
Try
search.Filter = String.Format("(&(SAMAccountName={0})(givenName={1}))", loginName, givenName)
search.PropertiesToLoad.Add("cn")
search.PropertiesToLoad.Add("SAMAccountName")
Dim result As SearchResult = search.FindOne()
Dim samaccountname As String = CStr(result.Properties("SAMAccountName")(0))
MsgBox(samaccountname)
If result Is Nothing Then
oReturn.FnCompletedSuccessfully = False
oReturn.colReturnItems.Add("Login Name provided isnt valid. Please try again.")
Else
oReturn.FnCompletedSuccessfully = True
End If
Catch ex As Exception
amaDBHelper.CatchErrors(oReturn, ex, "IsValidADLogin Error")
End Try
Return oReturn
End Function
But when I try to msgbox the value I get a Object reference not set to an instance of an object. error.
"Okay, I give up: which is NOT a real programming language????"
Michael Bergman
"Well yes, it is an Integer, but it's a metrosexual Integer. For all we know, under all that hair gel it could be a Boolean."
Tom Welch
"Let's face it, the average computer user has the brain of a Spider Monkey."
Bill Gates
|
|
|
|
|
|
You're joking, right? Think question isn't answerable.
"Save data" is a very generic term and can mean anything. Saving data to what? A file? What kind of file? A database? A file server? An FTP server? Web server? the Registry??, ... What kind of data?? There's so many ways to persist data in som many places that it's impossible to answer your question.
|
|
|
|
|
a data base of some sort..
sorry im new to these things ! im just starting to learn VB from the net and i almost know nothing.. help will be appreciated
|
|
|
|
|
I highly suggest picking up a book on VB.NET for beginners. If you're that new to this, you really need to learn the basics of OOP and the .NET Framework before you try and tackle a project that deals with a database.
|
|
|
|
|
will do ! thankx for the advice !
|
|
|
|
|
I'm working on a shoppingCart and try to delete multiple rows at once, but get error message:
"Collection was modified; enumeration operation may not execute."
Here is my code:
Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
For Each row As GridViewRow In GridView1.Rows
Dim chk As CheckBox = CType(row.FindControl("Remove"), CheckBox)
If Not chk Is Nothing AndAlso chk.Checked Then
Dim ID = New Guid(GridView1.DataKeys(row.RowIndex).Value.ToString())
StoreManager.RemoveItem(ID)
End If
Next
End Sub
Code for:
Class StoreManager
Public Shared Sub RemoveItem(ByVal id As Guid)
ShoppingCart.Remove(id)
End Sub
Code for:
Class ShoppingCart
Public Sub Remove(ByVal id As Guid)
For Each existingProd As OrderedProducts In _items
If id = existingProd.ID Then
_items.Remove(existingProd)
End If
Next 'error calls this line!!!
End Sub
Not sure how to fix error!
|
|
|
|
|
You cannot use For/Each/Next on a collection if you're going to modify the collection. You have to use For/Next with an indexing variable, and you have to iterate over the collection backwards, meaning you start at the end and work your way back to the beginning.
For i As Integer = GridView1.Rows.Length - 1 to 0 Step -1
.
.
Next
|
|
|
|
|
Hmmm, I tried this but still get same error
For i As Integer = GridView1.Rows.Count - 1 To 0 Step -1
Dim row As GridViewRow = GridView1.Rows(i)
Dim chk As CheckBox = CType(row.FindControl("Remove"), CheckBox)
If Not chk Is Nothing AndAlso chk.Checked Then
Dim ID = New Guid(GridView1.DataKeys(row.RowIndex).Value.ToString())
StoreManager.RemoveItem(ID)
End If
Next
|
|
|
|
|
Ok, found the problem and fixed it:
Public Sub Remove(ByVal id As Guid)
For i As Integer = _items.Count - 1 To 0 Step -1
Dim existingProd As OrderedProducts = _items(i)
If id = existingProd.ID Then
MsgBox("Found Product! Count: " & _items.Count.ToString() & "items")
_items.Remove(existingProd)
MsgBox("Deleted Product! Count: " & _items.Count.ToString() & "items")
End If
Next
End Sub
Thanks a lot!!!
|
|
|
|
|
I am trying to write a program that will search the hard drive for files using windows service in vb.net. I already created the service, but I am not sure if my code to search for files is correct. Does anyone have any suggestions or samples on how to search for files using vb.net. Here is the code that I have below:
Protected Overrides Sub OnStart(ByVal args() As String)
' Add code here to start your service. This method should set things
' in motion so your service can do its work.
Timer1.Enabled = True
SearchFiles(".txt")
End Sub
Protected Overrides Sub OnStop()
' Add code here to perform any tear-down necessary to stop your service.
Timer1.Enabled = False
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
'Check if the event log exists
If Not System.Diagnostics.EventLog.SourceExists("MyService") Then
'Create Log
System.Diagnostics.EventLog.CreateEventSource("MyService", "Myservice Log")
End If
EventLog.Source = "MyService"
'Write to the log
System.Diagnostics.EventLog.WriteEntry("MyService Log", "This is log on " & _
CStr(TimeOfDay), EventLogEntryType.Information)
End Sub
Private Sub SearchFiles(ByVal FileType As String)
Dim FilePath As String = "c:\"
Dim rootDi As New DirectoryInfo(FilePath)
Dim Di As DirectoryInfo
For Each Di In rootDi.GetDirectories
Directory.GetFiles(FilePath, FileType)
Next
End Sub
Please help!
jds1207
|
|
|
|
|
I would just use File.Exists method. Or were you trying to list each file that you searched?
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
First, scrap this service. If you can't write the code to search for files in a normal app, writing it as serice will only serve to frustrate you to death. Besides, the way you've written this code demonstrates a lack of understanding how Services work, how to write them, and most importantly, how to communicate with them to get them to do something useful.
The Timer isn't doing anything other than creating an event log on every tick of the timer.
You have no method of calling your function. Sure, it CAN work as a search, but you have no methods in here that allow for communication with the service in any way, so you have no way to call the search code.
Services require you to do a lot more planning up front. There's no such thing a "whipping one togther" like you can with a Console or Windows Forms app.
There's nothing in this code to salvage to get a working service. This thing really does need to be scrapped.
Simplify your code and get a working search in a Console or Windows Forms app first. The experience you get with that will show you what a search needs for input and what it can return as output and how it needs to be returned. After that, you can add threading support, which will give you the basis for writing a service that's going to work. You can't do this with a Timer...
|
|
|
|
|
I have started working on a search in a windows forms app but when I try to run the program I get the following security Exception
"Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
Here is my code:
Dim FilePath As String = TextBox1.Text
Dim FileType As String = TextBox2.Text
Dim diContents As New DirectoryInfo(FilePath)
Dim di As FileInfo
Dim filename As String = ListBox1.SelectedIndex
Dim testname As String
For Each di In diContents.GetFiles
Dim dirs() As String = Directory.GetFiles(FilePath & di.Name)
For Each filename In dirs
testname = System.IO.Path.GetFileName(filename)
Dim fileTest As String = testname.Remove(0, (Len(testname) - 3))
If UCase(fileTest) = FileType Then
ListBox1.Items.Add(testname)
End If
Next
Next
End Sub
Just to explain what I am trying to do, I want to enter the file path into the textbox where I want to search for the files. I want to enter the file extension(.txt, .mp3) into a textbox to specific what type of file I am looking for. Once the files are found, add them to the list box on the form. Is this code correct?
This line of code(Dim diContents As New DirectoryInfo(FilePath)) is highlighted when error occurs.
Any ideas?
jds1207
|
|
|
|
|
Nowhere in your code is there any provisions for handling the inevitable "access denied" error. Your code probably bombed in the root of your C: drive on a folder called "System Volume Information". You have to put some of this code in Try/Catch blocks to handle this eventuallity and deal with it as you must.
|
|
|
|
|
Don't tell me, tell the OP. That way, he'll get the email notification that you replied, not me.
|
|
|
|