|
Yes, i want to know how to check this using vb
|
|
|
|
|
Ok, i think you will need to do some further research, but this can be both checked and set using VB and WMI.
The link below has a script which can perform this from the command line;
http://forums.whirlpool.net.au/forum-replies-archive.cfm/919407.html[^]
What you will need to do is look for other examples (there are some on CP) on making WMI calls from VB, and then translate the script version calls to suit.
Happy problem solving!
|
|
|
|
|
Hi,
We are in the process of building a new enterprise application, that would comprise of an Oracle database, and a VB.NET application. Now my request to you all is to suggest the optimal architecture, in terms of technology, stability, maintenance, etc, bearing in mind that we would like to have a multi-tier application, with a thin client, and 1 to n business/persistence layers.
The application would be used by users who might be geographically separated.
Would appreciate your inputs on:
Winforms Vs ASP.NET?
Communication,
Data persistence,
Performance,
Any other criterion that you might consider important.
Your inputs would be highly appreciated.
Cheers/RB
|
|
|
|
|
RajeevBhatt wrote: Winforms Vs ASP.NET?
RajeevBhatt wrote: Communication
RajeevBhatt wrote: Performance
Windows forms (generally) give a faster, and more direct interactive experience to the user. Development will be easier. You will not be dependent on internet connections (or quality thereof)
RajeevBhatt wrote: The application would be used by users who might be geographically separated.
This is the key question, and I warmly suggest that you get a more committed answer from the customer.
RajeevBhatt wrote: Data persistence
In the case of "geographically separated users" ASP.NET (a web application) is much much easier for the application / data administrator(s), and will likely be much cheaper to maintain, and develop in the long run. System updates / patches / fixes go live instantly for all users, and all data returned is "live" at all times.
RajeevBhatt wrote: Any other criterion that you might consider important.
You should be asking the customer this.
(By the way, "customer" can also mean "your boss".)
My advice is free, and you may get what you paid for.
|
|
|
|
|
It is very, very rude to post the same question in more than one forum!
For future reference, decide which forum most suits your question and post it there and only there.
In this case either 'General Database' or 'Design and Architecture' would seem most appropriate.
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 am using vb.net 2003 for a stand alone windows program. I access an Access 2002 database file via Jet 4.0 and OleDbDataAdapter.
The program is like a "check book" for commercial fishermen to track their landings in relation to the amount of "quota" that they have been assigned. The program is structured so a fisherman can enter multiple boat names and track each one seperately. To work on a particular boats account, the fisherman would select a boat name from a drop down list. The boat name is then captured and assigned the string variable name of "xid" and in a Module have this code: <pre>Public xid as String</pre>
I used the DataAdapter Configuration Wizard to setup the data connection and assign the DataAdapter and DataSet. I went into Wizard generated code and manually entered a WHERE clause to filter the data for the selected boat. Doing this the program works fine. The code that works is: <pre>... WHERE [Boat Name] = '" & xid & "'</pre> .
However, if I return to the Designer view I get an error message: The variable 'xid' is either undeclared or was never assigned. And the entire SELECT statement is erased.
If I try letting the Wizard generate the WHERE clause when I enter: <pre>... WHERE [Boat Name] = '" & xid & "'</pre>, the code that is generated is has double double quotas as: <pre>... WHERE [Boat Name] = '"" & xid & ""'</pre> , and this does not show data on my form.
I have gone through every possible combination of single quote and double quotes and can not get the wizard to produce the syntax that works. And if I manually edit the wizard generated code the program works, but I can not return to the Designer view.
Does any one have a suggestion or solution?
|
|
|
|
|
The problem is that you are trying to apply Access techniques on vb.net.
The wizard does not, and will not ever understand that WHERE [Boat Name] = '" & xid & "' means that you want to use a variable.
Try writing the sql sentence in the wizard, and apply your variable like so: WHERE [Boat Name] = @xid . Then, in your vb.net code, before you call the DataAdapter.Fill method pass your variable's value to the adapter's parameter collection.
Something like: DataAdapter.SelectCommand.Parameters.Add("@xid", NVarChar).Value = xid (you probably have to check for the correct syntax, but something along these lines anyway)
As an added bonus you will be using the safe way to use parameterized queries (much less risk of an sql injection attack).
My advice is free, and you may get what you paid for.
|
|
|
|
|
Thanks for the reply. I would like to get this to work properly. This is my first attempt at programing with vb.net and using a database. In the past all of my projects used text files for input an writing. This is very different.
I made the change to the WHERE clause in the Wizard to <pre>... WHERE [Boat Name] = @xid</pre>
Now in my form I have this code:
<pre>OleDbDataAdapter1.SelectCommand.Parameters.Add("@xid", NVarChar).Value = xid
OleDbDataAdapter1.Fill(QuotaPounds1.Balance)</pre>
NVarChar is underlined with the explanation that it is not declared. If I edit this to VarChar it remains underlined with the explanation that it is not declared. If I make it Char, it is still underline but now the explanation is that it is "a Type and so is not a valid expression". I thought that the value in that spot was supposed to be a "Type".
Any guidance you can provide on the syntax here would be most appreciated.
|
|
|
|
|
You can check from the intellisense what sort of object or value the code is expecting. In this case SqlDbType.NVarChar .
To see how it works, don't paste my code in there but type in SqlDbType. and see what the editor suggests.
If the editor does not suggest anything, or the code still gets underlined, go all the way to the top of your code, above the Public Class BlaBlaBla bit, and add: Imports System.Data.SqlClient (so this should be the very first line of code), and then try again.
My advice is free, and you may get what you paid for.
|
|
|
|
|
Hi Everyone....
I have developed an application using vb.net and sql server 2000.
now is there any option by which i can bind my all database and its environment at the time of deployment and creating setup? So that client should not need to install any software explicitly.
Please Help Me .....
|
|
|
|
|
Fire up Bingle and search on something like 'vb.net setup project'. You will find lots of help there.
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 wrote following code
Imports System.Threading
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim s As New ThreadStart(AddressOf progress)
Dim t As New Thread(s)
t.Start()
End Sub
Sub progress()
For x As Int32 = 1 To 10000
ProgressBar1.Value += 1
Next
End Sub
End Class
I want to increase progress bar value within separate thread. When i run this code it wasn't run as i suppose and it threw Invalid operation exception. It's message is "Cross-thread operation not valid: Control 'ProgressBar1' accessed from a thread other than the thread it was created on."
What happened here. Please someone explain it.
|
|
|
|
|
You cannot access form from another thread. To do this, you should write:
Invoke(New MethodInvoker(Sub() ProgressBar1.Value += 1))
Die Energie der Welt ist konstant. Die Entropie der Welt strebt einem Maximum zu.
|
|
|
|
|
Where should i place this code? please explain it with my example.
|
|
|
|
|
Instead of
ProgressBar1.Value += 1
just replace this line
Die Energie der Welt ist konstant. Die Entropie der Welt strebt einem Maximum zu.
|
|
|
|
|
|
Pasan,
Pasan148 wrote: I want to increase progress bar value within separate thread. When i run this code it wasn't run as i suppose and it threw Invalid operation exception. It's message is "Cross-thread operation not valid: Control 'ProgressBar1' accessed from a thread other than the thread it was created on."
You can achieve this very easily using the background worker class (http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx[^]).
Just enable progress change and supports cancellation on the background worker object. Then, in the Do_Work sub, report progress, and you can easily update your progressbar in the progresschanged event.
Hope this helps.
He who goes for revenge must first dig two graves.
|
|
|
|
|
I am trying to dissasemble a .net dll via reflector, one that has been in use in our company for ages, as practice. My future task will be to produce similar dll-a that are com interoparabile and activex compliant.
I am doing this in VB.net, and I have already been told that this is a big no-no, dlls of this sort are supposed to be made with C++ people say. I would guess that they are stating this because C++ uses pointers (which are heavily used in many DLLs when it comes to pointing to a pointer - i.e. memory location that holds particular relevant info).
Be as it may, I wish to proceed building this dll in vb.net to see how far I can get before I am forced to switch to C++ or C#...
I have already made a lot of fixes to the code, thus reducing the number of errors from over 120 to 30 which is, I would guess, a good start, but now I am facing several errors that are above my level of knowledge (I am a beginner after all) and I would like to get some information from people who are more experienced than me.
* First problem I encountered is the following: (this is an excerpt of code dealing with events that happen on a SERIAL port).
Public Custom Event OnCTS As OnCTS
AddHandler(ByVal value As OnCTS)
Me.OnCTS = DirectCast(Delegate.Combine(DirectCast(Me.OnCTS, Delegate), DirectCast(value, Delegate)), OnCTS)
End AddHandler
RemoveHandler(ByVal value As OnCTS)
Me.OnCTS = DirectCast(Delegate.Remove(DirectCast(Me.OnCTS, Delegate), DirectCast(value, Delegate)), OnCTS)
End RemoveHandler
End Event
This is what the reflector did for me, unfortunately the first "DELEGATE" keyword after DirectCast has an error attached to it: "expression expected". I have tried using "raiseevent" instead but if I use that, another piece of code later will not work.
Currently I have this:
Public Custom Event OnCTS As OnCTS
AddHandler(ByVal value As OnCTS)
End AddHandler
RaiseEvent()
End RaiseEvent
RemoveHandler()
End RemoveHandler
End Event
But I do not know the proper syntax for this nor where to begin. I have only recently started doing event driven code.
* A similar error (DELEGATE keyword, "keyword does not name a type") happens in this line of code:
Me.parent.Invoke(DirectCast(New EventHandler(AddressOf callback.ToMainThread), Delegate))
* The third problem is in this line of code
Dim key As New RegKey(&H80000002)
&H80000002 - error code "constant expression not representable as UINT, here is the enumeration for the above mentioned constant.
Public Enum VasKeys ' as uint32 Here I had to remark away the "as uint32"
' Fields
ClassesRoot = &H80000000
CurrentUser = &H80000001
LocalMachine = &H80000002
Users = &H80000003
End Enum
* The fourth problem happens in this example of code:
Dim bytes As Byte() = SerialParser.StringToByteArray(str)
flag2 = Win32Serijski.WriteFile(Me.m_handle, bytes, bytes.Length, (numBytesWritten), o)
Second line, 2nd parameter "bytes" states that: " Value of type '1-dimensional array of Byte' cannot be converted to 'Byte'. "
The pinvoke looks like this:
<DllImport("kernel32", EntryPoint:="WriteFile", SetLastError:=True)> _
Private Shared Function WriteFile(ByVal handle As IntPtr, ByRef bytes As Byte, ByVal numBytesToWrite As Integer, ByRef numBytesWritten As Integer, ByRef overlapped As OVERLAPPED) As Integer
End Function
* Next is the problem of casting (BR is BaudRate)
Private BR As Integer = &H2580
dcb.BaudRate = DirectCast(Me.BR, UInt32)
It says it cannot cast integer to UINT32
* The fifth problem is as follows
Win32Serijski.GetCommState(Me.m_handle, AddressOf dcb) where dcb is a structure, and addressof demands a method so it wont accept dcb
Here is my DCB structure
Public Structure DCB
Public DCBlength As UInt32
Public BaudRate As UInt32
Public Flags As UInt32
Public wReserved As UInt16
Public XonLim As UInt16
Public XoffLim As UInt16
Public ByteSize As Byte
Public Parity As Byte
Public StopBits As Byte
Public XonChar As Byte
Public XoffChar As Byte
Public ErrorChar As Byte
Public EofChar As Byte
Public EvtChar As Byte
Public wReserved1 As UInt16
End Structure
* Finally I am having problems with the callback wrapper
wrapper = New CallbackWrapper(Me) '{.DoOnCTS = True, .BoolData = Me.m_old_cts}
It will not accept the {} portion stating that Value of type 'Jebemtisvepospisku.Port' cannot be converted to 'Integer'.
This is my callback wrapper:
Friend Class CallbackWrapper
' Methods
Friend Sub New(ByVal parent As Jebemtisvepospisku.Port)
Me._parent = parent
End Sub
Friend Sub ChangeToMainThread(ByVal o As Object, ByVal ea As EventArgs)
Me._parent.DoEvent(Me)
End Sub
' Fields
Friend BoolData As Boolean = False
Friend DoOnCTS As Boolean = False
Friend DoOnDCD As Boolean = False
Friend DoOnDSR As Boolean = False
Friend DoOnForceClose As Boolean = False
Friend DoOnRead As Boolean = False
Friend DoOnRI As Boolean = False
Friend DoOnWritten As Boolean = False
Friend IntData As Integer = 0
Private _parent As Jebemtisvepospisku.Port = Nothing
Friend StringData As String = Nothing
End Class
I have no idea why the value of my .port class turns out to be anything, it should not have a value yet the callback wrapper (which I copy pasted from another example) requires an integer. I was trying to handle threading, and this SHOULD in theory be used to switch between main thread and other threads , depending on which event occurs.
I wish to thank you for your help (if any, lol) in advance!
|
|
|
|
|
Hi,
I will attempt and answer a couple of your issues in separate messages, so they can expand individually if required.
try this:
Public Enum VasKeys as uint32
ClassesRoot = &H80000000U
CurrentUser = &H80000001U
LocalMachine = &H80000002U
Users = &H80000003U
End Enum
there are a couple of suffixes that indicate a different type, U means unsigned.
it is documented here[^].
|
|
|
|
|
Now thats a good tip, I was aware of the various types but I did not know how to easily fix problems like the above.
|
|
|
|
|
Fixed, in this case "UL" was the correct suffix to "cast" the number to UINT32
|
|
|
|
|
that would be "UI" not "UL", in .NET "long" variables take 64 bit, you don't need that, do you?
|
|
|
|
|
|
the prototype should indicate either an array or a pointer, so try this:
<DllImport("kernel32", EntryPoint:="WriteFile", SetLastError:=True)> _
Private Shared Function WriteFile(ByVal handle As IntPtr, ByRef bytes As Byte(), ByVal numBytesToWrite As Integer, ByRef numBytesWritten As Integer, ByRef overlapped As OVERLAPPED) As Integer
End Function
I made bytes an array of bytes, not a single byte.
I expect that to work for you, I haven't done it in VB.NET yet, I normally do C# (and P/Invoke from C# to C).
|
|
|
|
|
That was my appraisal as well, I did "fix" the pinvoke method by adding the () making bytes an array BUT as I made that change I thought to myself "that probably wont work" and so I decided to ask for help.
I havent yet figured out the ins and outs of pinvoking so I am still overly cautious to change things. Love the wiki, hate the "trial and error" part of pinvoking
|
|
|
|
|