|
I want to change the Text of a Menuitem dynamically in runtime. I can get a Menuitem in the
Menuitems collection, but it's Name property is empty.
For Each fp In My.Forms.GetType.GetProperties
If fp.Name = "BaseForm" Then
For Each mnu As MenuItem In Me.Menu.MenuItems
But in property window, the Menuitem has Name property, it's same as a name of field variable, like: MnuBaseFile
|
|
|
|
|
The Problem is that you ask the wrong question to the wrong partner.
As I understand :
MenuItem is a Control on your Form - which type has it ?
Why do you search inside the Forms.Properties ? You should search it inside the Form.Controls-Collection. I could specify it with more information from you.
|
|
|
|
|
Hello !
I'm creating a vb.net program that will use a sql server database. But for a lot's of record there's a document or image attached. I know that I can save the file on a folder and keep on database only the file path.
But I've read something about FileStream storage in Sql server 2008 , or the possibility to save an entire file on a Varbinary(MAX) filed.
So I'm asking if is a good idea to save files inside the database ?
Thank you !
|
|
|
|
|
That depends on what the app has to do with the files. Storing them in the database is a good idea in many cases, but offers no benefits in others.
One benefit of using the database is that you can implement versioning of the files.
Another is that it makes hacking the files more difficult.
|
|
|
|
|
The application need only to open the file ( and display its content on a control , or open with default programs on windows ). Also if the user want to change the file that is attached to a record ( for example has saved the wrong file and needs to save another file ).
So , to be more clear , the application only save a file an open it , but there's no need to modify this file.
|
|
|
|
|
Then it sounds like you want the file system.
|
|
|
|
|
The problem that I have using filesystem , is that sometimes I need to backup and restore the database.And in this case is difficult to put all the files in the backup. lso is the problem with the synchronization , I mean when the database has a reference to a file , but this file is deleted or renamed on file system.
|
|
|
|
|
|
|
And what about performance using the file contents on these cases :
- Saving the file on a folder
- Using FileStream
- Saving on a VARBINARY(MAX) fields.
( Of course supposing that the file may be on whatever size ).
|
|
|
|
|
In the second link I posted, there are some measurements in the end. Have a look at those.
|
|
|
|
|
I prefer streaming files in database. In many cases it payed back - specially in backups.
|
|
|
|
|
where can I read more about it , and is this method suitable for large files ?
|
|
|
|
|
I worked mostly with pictures with up to 4MB, but tried up to 1GB files (MySQL). Pay attantion to setting of database to allow large files.
|
|
|
|
|
ok , but where can I read more about this method ?
|
|
|
|
|
I´ve learned a lot from here:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=4630&lngWId=10
|
|
|
|
|
Hello !
On a VB.net application , how can I find some information about SQL server ( programmatically within the vb.net program )
- IF sql server is installed and currently running ( on a given Pc name or network path ).
- If is a SQL server or a SQL server Express
- If Sql server is installed with a default instance or has a named instance.
- Find the Instance name( if available )
- If a database exist or no in a sql server
Thank you !
|
|
|
|
|
An easy way is to use SqlDataSourceEnumerator . You can use GetDataSources[^] method which should return
- server name
- instance name
- version
What comes to a database existence, you need to succesfully open a connection to the SQL Server instance in order to get that information. You basically have two possible approaches
- use a login that has necessary privileges to query for example sys.databases[^]
- try to open a connection to a predefined database and see if it fails or not.
|
|
|
|
|
- Sorry but the article on your link speak only for SQL server 2000 and 2005. Does it work for other sql server versions ?
- and what about my first questions , so how can I check if Sql server is installed and is running on a given PC name or network Path ?
Thank you !
|
|
|
|
|
As far as I know, it should work with newer installations.
The enumaration is done by communicating with SQL Browser. So it needs to be on in order to find the instance. If SQL Server and SQL Browser are stopped, this won't work.
Another way to do this is to use SMO and use SmoApplication.EnumAvailableSqlServers[^].
However, to ensure if the SQL Server is installed on a computer even if the services are down, I guess you need to contact the server and run for example a WMI query to find out if the program is installed or not. For this you would query Win32_Product[^] class.
|
|
|
|
|
Pls i need help in creating a report in vb.net using crystal report or any reporting platform available.
thanks
|
|
|
|
|
You never said what exactly you're having a problem with.
|
|
|
|
|
do you really want to do reporting in crystal reports?
|
|
|
|
|
I try to use reflection to get a list of member fields in a form class.
Public Class BaseForm
Inherits System.Windows.Forms.Form
......
Friend WithEvents MnuBaseFile As System.Windows.Forms.MenuItem
Friend WithEvents MnuBaseWindow As System.Windows.Forms.MenuItem
Friend WithEvents MnuBaseFileExit As System.Windows.Forms.MenuItem
Friend WithEvents BaseFormTimer As System.Timers.Timer
Friend WithEvents MenuMainSeparator1 As System.Windows.Forms.MenuItem
Friend WithEvents HelpProvider As System.Windows.Forms.HelpProvider
.....
Dim fi As System.Reflection.FieldInfo() = My.Forms.BaseForm.GetType().GetFields()
But I failed, the length of fi is zero, the fi is empty array.
|
|
|
|
|
The GetFields method with no parameters returns only public fields. Try using the other overload and specifying what you want to search for by defining the binding flags. For example:
Dim fi As System.Reflection.FieldInfo() = My.Forms.BaseForm.GetType().GetFields(BindingFlags.NonPublic Or BindingFlags.Instance)
For more information, see: Type.GetFields Method (BindingFlags)[^] and BindingFlags Enumeration[^]
|
|
|
|