|
Hi,
I am trying to add a 3rd party dll(C++) to my application which is created on vb.net. when i tried to add that dll as reference i got a error as "A reference to <file location=""> could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component."
When i checked this in online, it seems to be unmanged code which is not accepted by .net and also they said P/Invoke command something like that.
But actually i dont know how to register a dll or use Pinvoke method or how i add a unmanged dll into my application, Can anyone help in this.
Thanks,
Nanda
|
|
|
|
|
Register a dll using regsvr32.exe. Do you know the functions exported by the dll?
|
|
|
|
|
Thanks JZ, But again.
how to do that with regsrv32.exe, for example my dll name is nanda.dll, where i have to do this and how and what was the output
Thanks,
Nanda
|
|
|
|
|
REGSVR32 filename.dll
But, if the .DLL is not COM-based, this wont work and you'll be forced to use P/Invoke to call the functions in the .DLL. You will not be able to set a reference to it and have VS import the functions for you.
|
|
|
|
|
Thanks Dave,
I tried but It throws a message box
<dll> was loaded, but the DllRegisterServer entry point was not found.
This file can not be registered.
I hope this dll is not com based
Can you please help me how to use P/Invoke with an example.
Thanks,
Nanda
|
|
|
|
|
You got that error because the .DLL is not COM-based. You'll have to use P/Invoke to get at the functions in that library. I hope you have the documentation on it.
http://www.pinvoke.net[^] has tons of examples.
|
|
|
|
|
Hi
I created store produce to insert selected values from checkboxlist into sql database and it gives me this error "Procedure or function SaveAdmin has too many arguments specified."
here is my store procedure
ALTER PROCEDURE [dbo].[SaveAdmin]
-- Add the parameters for the stored procedure here
@Perno int,
@Client_id int,
@Region_id int,
@Service_id int
AS
INSERT INTO Admin(Perno, Client_id, Region_id, Service_id)
VALUES(@Perno, @Client_id, @Region_id, @Service_id)
and here is my vb.net code
cmdStandby.CommandText = "SaveAdmin"
cmdStandby.CommandType = CommandType.StoredProcedure
cmdStandby.Connection = sqlstandby
cmdStandby.Parameters.AddWithValue("@Perno", lblEmpNo.Text)
cmdStandby.Parameters.AddWithValue("@Client_id", ddlClient1.SelectedValue)
For Each li In ChkRegion.Items
If li.Selected = True Then
cmdStandby.Parameters.AddWithValue("@Region_id", li.Value)
End If
Next
For Each li In ChkService.Items
If li.Selected = True Then
cmdStandby.Parameters.AddWithValue("@Service_id", li.Value)
End If
Next
cmdStandby.ExecuteNonQuery()
thanx in advance
Mamphekgo
|
|
|
|
|
Hi, I have never used add with value but I assume it adds the parameter to the collection as well as adding the value. Try using .value =
Even if that worked you would still only get one 'set'passed through as your loops are replacing the value each iteration. Your executenonquery needs to be inside the loop, and the loop needs to add each type of value to the set.
Looking at what you are trying to do I suspect that you should be normalising the database a bit more, unless you want each row to contain the employee and client data for each service ID and region ID
Sort of like: (I don't think this is quite right as I an not sure what you controls are but you should get the idea)
cmdStandby.CommandText = "SaveAdmin"
cmdStandby.CommandType = CommandType.StoredProcedure
cmdStandby.Connection = sqlstandby
cmdStandby.Parameters.Add("@Perno", SqlDbType.Int)
cmdStandby.Parameters.Add("@Client_id", SqlDbType.Int)
cmdStandby.Parameters.Add("@Region_id", SqlDbType.Int)
cmdStandby.Parameters.Add("@Service_id", SqlDbType.Int)
For Each li In ChkRegion.CheckedItems
cmdStandby.Parameters("@Perno").Value = CINT(lblEmpNo.Text) 'or the proper conversion
cmdStandby.Parameters("@Client_id").Value = ddlClient1.SelectedValue 'or should this be selected index? If value what is it ? Text, integer etc
cmdStandby.Parameters("@Region_id").Value = li.Value '(?)
cmdStandby.Parameters("@Service_id").Value = li.Value '(?)
cmdStandby.ExecuteNonQuery()
Next
For Each li In ChkService.CheckedItems
cmdStandby.Parameters("@Perno").Value = CINT(lblEmpNo.Text) 'or the proper conversion
cmdStandby.Parameters("@Client_id").Value = ddlClient1.SelectedValue
cmdStandby.Parameters("@Region_id").Value = li.Value '(?)
cmdStandby.Parameters("@Service_id").Value = li.Value '(?)
cmdStandby.ExecuteNonQuery()
Next
|
|
|
|
|
Is suspect your problem is here:
For Each li In ChkService.Items
If li.Selected = True Then
cmdStandby.Parameters.AddWithValue("@Service_id", li.Value)
End If
Next
This loop is going through a list and checking if it's selected. For each value selected you're adding another parameter (with the same name) to the Parameters collection. If there is more than one item selected, your code is adding more than the 4 parameters to the SQL call.
|
|
|
|
|
hi,
Is there any free activex component that support secure ftp?
|
|
|
|
|
|
Does anyone knows how to share the value of a particular variable but are declared in different class?
|
|
|
|
|
declare the variable as shered variable so it can be accessed and modified. For example
Public Class Utility<br />
Public Shared SharedVariable As Integer<br />
End Class
hope this helps
|
|
|
|
|
Use a property
Dim strVar As String = "la la la"
Public Property SharedMyVariableWithTheWorld() As String
Get
Return strVar
End Get
Set(ByVal value As String)
strVar = value
End Set
End Property
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
No no no, not how to do it!
I can drag and drop lines between list boxes no problem either as a move or a copy and I have got it to check that the item does not exist in the target box BUT.....
Where I am stuck is that if I drag a line, and drop it in the SAME box, it checks that it is there and does nothing EXCEPT if it is a move, rather than a copy, the line has already been removed from the source box.
The boxes are in separate child forms (of the same type) in a MDI comtainer. Looking at the properties of sender it gives the handle - which actually would be useful - if I could get at it. If I can see this information by hovering over the sender, why can I not get at it with intellisense?
Does any one have any ideas how (otherwise) I can differential between the source and target list boxes?
What I find a bit strange is that the list still seems to contain the string being dragged, even though it was removed in the MouseMove routine.
If (e.Effect = DragDropEffects.Copy Or e.Effect = DragDropEffects.Move) Then
'See if the name is already in the list
If lstCollection.FindStringExact(item) = ListBox.NoMatches Then
'The font does not exist in the list
If (indexOfItemUnderMouseToDrop <> ListBox.NoMatches) Then
'There is something under the mouse so insert
Me.lstCollection.Items.Insert(indexOfItemUnderMouseToDrop, item)
Else
'There is nothing under the mouse so add
Me.lstCollection.Items.Add(item)
End If
End If
End If
This is where it is removed
' If the drag operation was a move then remove the item.
If (dropEffect = DragDropEffects.Move) Then
lstCollection.Items.RemoveAt(indexOfItemUnderMouseToDrag)
' Select the previous item in the list as long as the list has an item.
If (indexOfItemUnderMouseToDrag > 0) Then
lstCollection.SelectedIndex = indexOfItemUnderMouseToDrag - 1
ElseIf (lstCollection.Items.Count > 0) Then
' Selects the first item.
lstCollection.SelectedIndex = 0
End If
End If
Thanks
David
|
|
|
|
|
Hello,
You can try out this code. I have used two Listboxes on a form.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As Integer
For i = 0 To 19
Me.ListBox1.Items.Add("Item " & (i + 1).ToString)
Next
End Sub
Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown
Try
ListBox1.DoDragDrop(ListBox1.SelectedItem, DragDropEffects.Copy)
Catch ex As Exception
MsgBox("Drag Error: " & ex.Message)
End Try
End Sub
Private Sub ListBox2_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox2.DragDrop
ListBox2.Items.Add(e.Data.GetData(DataFormats.Text))
End Sub
Private Sub ListBox2_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox2.DragEnter
If e.Data.GetDataPresent(DataFormats.Text) Then
e.Effect = DragDropEffects.Copy
Else
MessageBox.Show("No Text Present")
e.Effect = DragDropEffects.None
End If
End Sub
I believe this should assist you.
Regards
Sumit Gupta
|
|
|
|
|
Hi Sumit, thanks for responding but it is not quite what I am trying to determine. I already have code that deals with that. What I need to know is how to identify which list box is the source and which is the target, bearing in mind that they are on different forms which are both identical children of the MDI parent.
David
|
|
|
|
|
In the ondrag event you can inspect e to determine the source. I did not read through the lot but identifying the source should be no problem. You could then set a flag that is external to both forms, inspect the flag when dropping. I have done this in a single form but not MDI.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Not at all a bad idea that. I will give it a whirl. Thanks.
David
|
|
|
|
|
Hi All!
I'm still wading into a long prepared-for project of mine. I've just hit the WYSIWYG HTML editor section and am already stuck. I'm using the following method to activate designmode in a WebBrowser control:
MyWebBrowser.Document.DesignMode = "On"
And then I load the attributes of the ActiveElement (The currently selected HTML element) into a PropertyGrid for editing. My problem is that while ActiveElement works with Buttons, TextBoxes and suchlike in which there is text to edit. It doesn't work with images and other elements that cannot be visually edited in designmode. the resize box appears around the image and drag-drop resizing works fine but the ActiveElement never shifts to the selected element. Any ideas on how to obtain the selected element regardless of it's type?
Thanks!
MrWolfy
modified on Wednesday, October 22, 2008 2:58 PM
|
|
|
|
|
I don't what you're execting with the MSHTML editor. It's not a full-fledged HTML editor. It allows you to do simple editing of the document, that's all. If there's some other editing you want to do outside of what's exposed, you'll have to implement your own editor extensions for that using the Win32 IHtmlEditDesigner[^] interface, which you'll find just about impossible to use from VB.
|
|
|
|
|
Hi and Thanks!
Ok! Thanks for the Link! I guess I'll have to do some more research!
Thanks Again!
MrWolfy
|
|
|
|
|
Hi Folks
Please excuse me if this is an incredible ingnorant question.
I've got 2 linklabels, Next and Previous. I'm using these to move through the images saved in my dataset.
However, looking up Linklabels in help you should be able to do something like LinkLabel1.Link.LinkData in order to set the Data Source. However I'm not getting this option after Link. All I'm getting is Link.Equals or Link.ReferenceEquals?
Can anyone help please?
Thanks alot
Kris MCP
|
|
|
|
|
Sounds like you're using the class instead of the instance.
The instance has Links collection and every item in that collection has LinkData property. LinkLabel.Link is a type used in Links collection.
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
Hi Mike
Sorry for the delay had one of those days!
Thanks for replying but I'm now totally confused. I've read your article and also read up on Instances withing VS 2005. However, there seems to be numerous types, ie, constructor, Property, Method etc.
Please can you offer a little more advise. Yes, I am newly qualified hence being lost.
Thanks alot
Kris
Kris MCP
|
|
|
|