|
Thanks for the feed back.
I am running VB6 and I get an error message "..Method or data member not found"
with the My_DataGrid.currentrow.cells
Any other suggestions
|
|
|
|
|
have a question that i hope someone can help me with.
I have over 25 years experience programming allen bradley,omron,automation direct plc'c, and have always used the hmi software and units that you would purchase from these vendors as well.
I am interested in learning visual basic, and was hoping someone could lead me in the right direction as to what would be a good book, web site etc., that could help someone who has no visual basic experience, learn how to use vb and connect to a plc and read data from the plc.
thanks
|
|
|
|
|
Hi,
I have an application where on a lot of my ASP.NET pages i need to add text boxes which collect First Name, last Name, Age, Company Name etc and has a button which when clicked enters the above mentioned data into the database.It needs to be entered to the same database table all the time.No, I cannot use session info. I wanna know if it is possible to create a custom web control which does this? So I can add it to my tool box and drag and drop onto my pages as and when I need it. I havent seen instances where you can create a control which does db operation. I know you can use User controls(.ascx) but that way, it needs to be included in every project and every one can see the code and know whatz happening behind it. Help is appreciated. Samples are appreciated even more!!!
Regards
RH
|
|
|
|
|
I am trying to run an insert for each row on a datagridview that is selected (checkbox on 0 column index). My problem is that the @articleID parameter is not selected from the correct row. I want the to pick up the articleID from the row that is being iterated through. Looks like the currentrow syntax isn't working. Any suggestions?
<br />
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
Dim myCmd As New SqlCommand("sp_Create_NewPriceListLine", MDIParent1.Conn)<br />
myCmd.CommandType = CommandType.StoredProcedure<br />
<br />
For Each Row As DataGridViewRow In Article_searchDataGridView.Rows<br />
Dim include As DataGridViewCheckBoxCell = TryCast(Row.Cells("Select_Article"), DataGridViewCheckBoxCell)<br />
<br />
If Row.Cells("Select_Article").Value = True Then<br />
MDIParent1.Conn.Open()<br />
Dim discountID As SqlParameter = myCmd.Parameters.AddWithValue("@discountID", Me.DiscountIdTextBox1.Text)<br />
discountID.Direction = ParameterDirection.Input<br />
<br />
Dim articleID As SqlParameter = myCmd.Parameters.AddWithValue("@articleID", Me.Article_searchDataGridView.Item(7, Me.Article_searchDataGridView.CurrentRow.Index).Value) 'Me.Article_searchDataGridView.CurrentRow.Index).Value)<br />
articleID.Direction = ParameterDirection.Input<br />
<br />
Dim userID As SqlParameter = myCmd.Parameters.AddWithValue("@userID", MDIParent1.userid)<br />
userID.Direction = ParameterDirection.Input<br />
<br />
Dim myReader As SqlDataReader = myCmd.ExecuteReader()<br />
<br />
myReader.Close()<br />
MDIParent1.Conn.Close()<br />
End If<br />
myCmd.Parameters.Clear()<br />
<br />
Next<br />
End Sub<br />
|
|
|
|
|
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.
|
|
|
|