For those new to message boards please try to follow a few simple rules when posting your question.
Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
Keep the subject line brief, but descriptive. eg "File Serialization problem"
Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
No advertising or soliciting.
We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
I have an vb.net 2013 application that use a SQL server database.
Currently I'm using sql server 2008R2.
To Backup / restore database from vb.net I'm using SMO.
But the problem is that when I try my application on sql server 2012 , the backup / restore functions doesn't work anymore , because the SMO files that my application use are for sql server 2008R2.
So I'm thinking is there any way to Backup restore a database that is independent from SQL server version ?
Thank you !
The SMO-libraries are for a specific version of SQL Server. You can use the backup and restore-commands without SMO. That way it should be possible to restore your backup on a newer (!) version of SQL Server. AFAIK, it doesn't work the other way around.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
Thank you !
But as I'm comfortable using SMO , is there any way to keep in different fodders , SMO files for a specific version of SQL server, and to alter when I need ? ( just an idea , I don't know if this can work ).
But the problem is that now , all these commands are always enabled even in some cases when shouldn't be. for example even nothing is copied , the Paste command is enabled. Event the textbox is empty and nothing is selected , the Copy command is enabled.
----Is there a way to fix this behavior ?
----Or maybe is there a way to not use a custom menu . but just to hide the items that I don't want in the default context menu , using TextBox.ConTextMenu.Popup event ?
So , I think it's better to consider the second solution , so to leave the contextmenu as default (not using a custom menu ) but just hide some items and leave those that I want , using ContextMenu.Popup. Is that possible ?
I tried a quick Google search on modifying the standard ContextMenu-popup and it doesn't look like there's an easy solution to this.
However, I think building your own and checking the conditions for enabling/disabling the menu entries isn't as difficult as you might think. Take a look at the Clipboard[^]-class - there are easy to use methods to check if and what the clipboard contains, e.g. Clipboard.ContainsText(). Combined with the sample Richard linked for you it should be rather straight forward.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
I don't know if you mean you want a code example for disabling the buttons in your Context Menu or your code doesn't work.
If your code doesn't work as it suppose to do just try this (after you disabled for example a button in your context menu):
If you mean that you don't have a code, I have a good example.
PrivateSub EditPaste_Click(sender AsObject, e As EventArgs) Handles EditPaste.Click
Dim iData As IDataObject = Clipboard.GetDataObject()
If iData.GetDataPresent(DataFormats.Text) Then
TextEditorBox.SelectedText = CType(iData.GetData(DataFormats.Text), String)
EndIfEndSubPrivateSub EditCut_Click(sender AsObject, e As EventArgs) Handles EditCut.Click
If TextEditorBox.SelectedText <> ""Then
TextEditorBox.SelectedText = ""Else
EndIfEndSubPrivateSub EditCopy_Click(sender AsObject, e As EventArgs) Handles EditCopy.Click
If TextEditorBox.SelectedText <> ""Then