|
This is what I was looking for... Thanks for your help
Not sure why I got downvoted either. Weird
|
|
|
|
|
Member 11915345 wrote: Not sure why I got downvoted either. Probably because you did not show that you had attempted anything, reversed.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mika Wendelius wrote: As a side-note, not sure why you got downvoted...
I down-voted the question, and having slept on it, I stand by my decision.
The OP has clearly made no effort to answer their own question. If you paste the question into Google, the answer appears within the first 10 results.
But why bother asking Google, when you can paste your question into a forum and get someone else to ask Google, sift through the search results, and present the answer to you on a silver plate? After all, this site was created to be a human search-engine, providing help to those who can't be bothered to help themselves, wasn't it?
And no, I didn't post an explanation for the down-vote. In my experience, that only leads to insults or arguments from the OP. I have yet to see anyone accept the criticism and adjust their approach to the site.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks for the explanation!
I agree that the OP could have Googled and tried to find solutions. However, another aspect is that if you don't quite know what you're looking for where do you start from? For experienced people it's often obvious what search terms to use and what to search for, but what if you're not familiar with the technology in the first place.
Don't get me wrong, I completely agree that people should do the background work properly before asking incomplete questions.
Especially I appreciate that you took time to explain the reason behind the downvote since it got me thinking about the threshold of answering a question at all.
|
|
|
|
|
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
....
For Each fp In My.Forms.GetType.GetProperties
If fp.Name = "BaseForm" Then
For Each mnu As MenuItem In Me.Menu.MenuItems
Here I can get mnu.text = &File,
But mnu.Name = "", Nothing.
And I try to use the following block:
Dim fi As System.Reflection.FieldInfo() = bfType.GetFields(BindingFlags.NonPublic Or BindingFlags.Instance Or BindingFlags.DeclaredOnly)
For Each f As System.Reflection.FieldInfo In fi
If (f.FieldType.Name.ToString() = "MenuItem") Then
mnuNameStr = f.Name.Remove(0, 1)
End If
Now I can get field's name, but I can't use field to set text for the menu.
How can I get a field's name, the Menuitem's name, then set the text for the Menuitem?
|
|
|
|
|
Sorry ... I don't understand what you trying to achieve ...
Could you explain it once more (perhaps with an example) ?
|
|
|
|
|
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 !
|
|
|
|