|
I really have to ask why you're even bothering with a DSN?? Do you know what a DSN is?? It's a connection string in a text file.
Since your code can use a connection string directly without the DSN, why are you even bothering with it?
|
|
|
|
|
The DSN is being setup for the Crystal reports that are initiated by the application.
Lost in the vast sea of .NET
|
|
|
|
|
OK. Crystal Reports doesn't exactly require using a DSN either, but whatever.
By default, users on Vista and 7 run as normal users, even if they are Admin accounts. UAC will usually prompt for admin creds if an app requires admin level priv's.
Add a manifest to your application and modify it to require admin priv's when it runs. See this[^] for the full details.
Warning! If UAC is turned on on Vista and 7, every time your app runs, it will ask for the users credentials or at least warn them that the app will be running as an admin.
|
|
|
|
|
Thanks Dave!
This worked very well in Windows 7 without breaking the app for my XP clients.
I was looking at your profile. Congratulations on all the MVP awards over the years! I don't post much on Codeproject, just a couple questions and a few answers a year, but I believe you've probably answered most of my posts. I see you hit 9 years as of today, March 12th, Congratulations...
Thanks again for your help!
Lost in the vast sea of .NET
|
|
|
|
|
give some codes for audit trail in vb.net
|
|
|
|
|
to audit what exactly?
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
No.
If you have a specific problem you're trying to solve with YOUR code, we can help with that. If you want someone to do work for you, like Google "vb.net audit trail examples" for you, you're on your own.
|
|
|
|
|
hey guys,
i am making a programming language in visual basic and i am stuck. i would like to add these things to it:
1. i would like to add if functions "if string1 = something {
enter code here
}"
2. i would like to add parameters such as what you saw in example 1 "{enter text here}"
3. i would also like to add classes "goto finnish" and it would execute code that is in the 'finnish' class
as i said, i am using visual basic 2010 and i am making it so when you press button1; it will execute code in textbox1. eg:
click button event
for each a as string in textbox1.text.split(system.environment.newline())
if a.contains("write ")
messagebox.show(a.substring(6))
end
end
|
|
|
|
|
have you made the compiler that will interpret this new language? or are you trying to add "helping" functionality to help you with projects?
have a read of this Create a language compiler[^]
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
i am not actually making a compiler, i am making an interpreter.
|
|
|
|
|
you will then need to look at how to make a parser as this will validate the code that you have entered
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
Repost from Quick Answers. That's not good behavior.
|
|
|
|
|
When I need to do scripting I usually just use VB, and then use the VBCompiler to create the assembly.
Public Function CreateObject(ByVal code As String) As Object
Dim vbCP As New VBCodeProvider
Dim dir As String = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
Dim Options As New CompilerParameters
Options.GenerateInMemory = True
Dim cr As CompilerResults
Options.ReferencedAssemblies.Add(dir + "System.Data.dll")
Options.ReferencedAssemblies.Add(dir + "System.XML.dll")
Options.ReferencedAssemblies.Add(dir + "System.Windows.Forms.dll")
Options.ReferencedAssemblies.Add(dir + "System.Data.DataSetExtensions.dll")
Options.ReferencedAssemblies.Add(dir + "Mscorlib.dll")
Options.ReferencedAssemblies.Add(dir + "System.dll")
Options.ReferencedAssemblies.Add(dir + "System.Drawing.dll")
Options.ReferencedAssemblies.Add(dir + "Microsoft.VisualBasic.dll")
Options.ReferencedAssemblies.Add(dir + "System.Web.Services.dll")
cr = vbCP.CompileAssemblyFromSource(Options, code)
If cr.Errors.Count > 0 Then
Return cr.Errors
End If
oAssy = cr.CompiledAssembly
Return Nothing
End Function
If you get an assembly, then you can use reflection to run the new assembly.
Here's a decent article which I used when I was starting on reflection.
Reflection in .NET[^]
|
|
|
|
|
My guess is, that you are having trouble phrasing your question.
By the look of your questions, you are not making a programming language, instead you are just trying to write a program ? (and perhaps this program is supposed to do something with languages ?)
So to answer your questions:
1. Conditions in VB.NET are simple:
If string1 = "Hello" Then
Else
End If
2. You can add parameters to executing code using Subs and Functions. A Sub will simply execute whatever code you write in it, and a function is otherwise the same, but it will return a value.
Public Sub ExecuteWhenTrue(Byval Par1 as String)
MsgBox(Par1)
End Sub
Public Function ExecuteWhenFalse(Byval Par1 as String) As String
Return "You are not very polite " & Par1
End Function
If string1 = "Hello" Then
ExecuteWhenTrue("Well, hello to you too!")
Else
MsgBox(ExecuteWhenFalse("buddy"))
End If
3. Just write a Sub with the code that you want to execute at the finish (of what ?)
If you mean when the user has given all the correct parameters, then just execute the sub once all your conditions (see point 1) are true.
If you mean when you close the program, then execute the sub in the Closing or Closed event of the form.
Good luck
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
i use this way,
Private Sub Editor_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.Alt AndAlso e.KeyCode = Keys.S Then
Me.Close()
End If
End Sub
is it possible to use select case?
cause i prefer that way..
|
|
|
|
|
Yes, you can use Select but for such a simple block of code there does not seem to be any real benefit.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Hello can anyone help me to serializer a class with a complex property
I can't serialize a class that contains this property
Public Property DTOCarrito() As IList(Of DTOCompraCarritoX)
Get
If _DTOCarritoList.Count = 0 Then
If CuponIngresado.Trim.Length = 0 Then
CuponIngresado = String.Empty
DTOCuponDetalle = Nothing
End If
End If
Return _DTOCarritoList
End Get
Set(ByVal value As IList(Of DTOCompraCarritoX))
_DTOCarritoList = value
End Set
End Property
I can serialize fine without this property, but when I add the property and try to serialize I get this message "error reflecting type '. DTOCompraX'." DTCompraX is the main class name.
This is the code to serialize
Dim dt As DTOCompraX
Dim dtc As DTOCompraCarritoX
Dim DTOclist As IList(Of DTOCompraCarritoX)
Dim dtp As DTOTipoProducto
dtc = New DTOCompraCarritoX()
dtp = New DTOTipoProducto()
DTOclist = New List(Of DTOCompraCarritoX)
Dim extraTypes(1) As Type
extraTypes(0) = dtc.GetType()
extraTypes(1) = DTOclist.GetType()
dt = New DTOCompraX()
Dim ot As Type
ot = dtc.GetType()
Dim fs As FileStream = New FileStream("c:\miobjeto.xml", FileMode.Create)
Dim xs As XmlSerializer = New XmlSerializer(dt.GetType(), extraTypes)
xs.Serialize(fs, dt)
fs.Close()</pre>
Thank you.
|
|
|
|
|
I am not sure how to resolve that. Have you tried to use List instead of IList, i.e.
Public Property DTOCarrito As List(Of DTOCompraCarritoX)
|
|
|
|
|
Need some help out there. To give an example of my problem suppose the following...
Public Module MathHelpers
Public Function Add(ByVal param1 As Object, ByVal param2 As Object) As Object
Return param1 + param2
End Function
End Module
And you wanted to be a bit more OOP by overloading the function to prevent unboxing and boxing you decide to do this. Also, not only for the aforementioned reasons you wanted to add 2 class objects that have something specific to these class objects that can be added. But leaving the parameter data type as Object will not suffice to capture the differences between say adding 2 class objects in comparison with 2 integer types. Does that make sense?
Public Module MathHelpers
Public Overloads Function Add(ByVal param1 As Integer, ByVal param2 As Integer) As Integer
Return param1 + param2
End Function
End Module
After running into this error[^]. I am bit unsure what to do next.
Since the MSDN hints that Classes can overload functions I decided if I could create a Static Class. Since that proved pointless all I want is to overload this function without creating an instance of it.
MSDN does poor job in this scenario telling me A) Why this is not encouraged to do and B) some helpful advice on how to encapsulate my functions/routines with overloading.
Any advice you can offer I would greatly appreciate.
If you need me to clarify anything just let me know.
|
|
|
|
|
Clark Kent123 wrote: MSDN does poor job in this scenario telling me A) Why this is not encouraged to do and B) some helpful advice on how to encapsulate my functions/routines with overloading.
Try overloading with using the keyword. It'll work, and I have no explanation why.
Bastard Programmer from Hell
|
|
|
|
|
within a module you dont use the overloads keyword as Modules dont have instances.
You can achieve the two functions by
Module Module1
Public Function add(ByVal param1 As Object, ByVal param2 As Object) As Object
Return param1 + param2
End Function
Public Function add(ByVal param1 As Integer, ByVal param2 As Integer) As Integer
Return param1 + param2
End Function
End Module
the above works as you are changing the signature of the function.
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
Thanks Simon for that response. Very helpful. What I am having a hard time grasping is how is the compiler supposed to know that your encapsulating this?
For instance we use keywords in VB to let the compiler know what we want to achieve; Class, Module, Integer, etc. So by removing the "Overload" keyword the compiler will just "know" that I want to encapsulate a sub/function within a module?
|
|
|
|
|
as Dave stated you mainly use the overloads keyword when you are creating an overloaded method from a base class. But in the instance of creating overloaded methods in the same class or module it uses infered overloading
have a read of this I found this useful in understanding the difference Overloads keyword in VB.NET[^]
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
Thanks that does help. I just wish that MSDN document I linked to in my original post just said "Get rid of the Overload keyword and you will be all set". I guess that's just wishful thinking on my end.
I did check the link out that you posted. I will bookmark it so I don't make the same mistake twice. Thanks.
|
|
|
|
|
Anytime
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|