|
There may be active uses on the db when you are trying to restore a backup..
|
|
|
|
|
thanks prdshukla
i think no other users who use the db because its a local machine and only 1 user, and in the end
of my code I set to nothing the server.
resDB.SqlRestore(sv)
sv.Refresh()
sv = Nothing
C# コードMicrosoft End User
2000-2008
「「「「「「「「「「「「「「「「「「「「「「「「「「「「
The best things in life are free
」」」」」」」」」」」」」」」」」」」」」」」」」」」」
|
|
|
|
|
Hi,
The post above is correct.
C#Coudou wrote: note: sometimes it goes successfully but sometimes got an error.
Next time, include the message of the error. It can be quite helpful.
Bastard Programmer from Hell
|
|
|
|
|
thanks Eddy Vluggen
Eddy Vluggen wrote: Next time, include the message of the error. It can be quite helpful.
the subject itself of this post is error message of my program.
but you gave me an idea what is the real error which is the inner exception, and i found out that some process are not close or dispose. so i added a kill process, and it goes smoothly and perfectly.
thanks you very much.
C# コードMicrosoft End User
2000-2008
「「「「「「「「「「「「「「「「「「「「「「「「「「「「
The best things in life are free
」」」」」」」」」」」」」」」」」」」」」」」」」」」」
|
|
|
|
|
Hi
I am trying to place a red rectangle around a control on a form using the PowerPacks RectangleShape.
I managed to do that if the control is on the form, but if the control is in container (groupbox, panel) i am getting wrong measurements.
Here is my code
Sub PutRedRectangle(ByVal _ctrl As Control)
Dim canvas As New Microsoft.VisualBasic.PowerPacks.ShapeContainer
Dim rect1 As New Microsoft.VisualBasic.PowerPacks.RectangleShape
canvas.Parent = Me.GroupBox1
rect1.Parent = canvas
rect1.Left = _ctrl.Left -1
rect1.Top = _ctrl.Top - 1
rect1.Width = _ctrl.Width + 2
rect1.Height = _ctrl.Height + 2
rect1.BorderWidth = 2
rect1.BorderColor = Color.Red
End sub
If I placed a textbox on a form, the code will work
If I placed a textbox in groupbox on a form, the rectangle will not be placed correctly around the textbox.
Is there special calculations or formula I should follow?
[EDIT]
Any other way of placing a red rectangle around a control is welcomed.
modified on Wednesday, September 7, 2011 6:32 AM
|
|
|
|
|
Are you sure that the textbox control is actually *in* the groupbox? When debugging, check _ctrl.Parent to see if it refers to the groupbox.
Also, PutRedRectangle can only be called once, as MSDN for the ShapeContainer specifically states that each container control can only have one ShapeContainer in it. If you call it multiple times, you are going to have to check for the existence of a ShapeContainer inside the container control (_ctrl.Parent control is the container) and use that when found, or create a new one when not found.
|
|
|
|
|
MicroVirus wrote: Are you sure that the textbox control is actually *in* the groupbox? When debugging, check _ctrl.Parent to see if it refers to the groupbox.
Yes, I checked, it is inside it.
MicroVirus wrote: Also, PutRedRectangle can only be called once
Thank you for this info, but my function create new Shape and new rectangle each time I call it (which is what I want for now) my next step (after fixing my current) is to remove the rectangle.
Well, you made me consider the .parent for the control I am sending and that help me to create a customized function if the .parent type is GroupBox
Sub PutRedRectangle(ByVal _ctrl As Control)
Dim canvas As New Microsoft.VisualBasic.PowerPacks.ShapeContainer
Dim rect1 As New Microsoft.VisualBasic.PowerPacks.RectangleShape
Dim _parent As Control = _ctrl.Parent
rect1.Parent = canvas
canvas.Parent = _parent
canvas.Name = "canvas_" + _ctrl.name
rect1.Width = _ctrl.Width + 2
rect1.Height = _ctrl.Height + 2
rect1.BorderWidth = 2
If TypeOf(_parent) is GroupBox
rect1.Left = _ctrl.Left - 1 - _parent.Padding.Left
rect1.Top = _ctrl.Top - 17 + (_parent.Margin.Top - _parent.Padding.Top)
rect1.BorderColor = Color.Red
Else
rect1.BorderColor = Color.Blue
rect1.Left = _ctrl.Left - 1 - _parent.Padding.Left
rect1.Top = _ctrl.Top - 1 - _parent.Padding.Top
End If
canvas.SendToBack
End Sub
Sub RemoveRedRectangle(ByVal _ctrl As Control)
Dim q = From c As Control In _ctrl.Parent.Controls Where c.Name.StartsWith("canvas_" + _ctrl.Name) Select c
q.First.Dispose
Me.Refresh
End Sub
It seem the groupbox has invisible header which should be calculated depends on the font size when assigning the .Top for the rectangle. ( I don't know how to get it)
Also, the Rect1.Top is affected with margin and padding if inside a groupbox, and it is not affected if inside a panel.
So, the above code works correctly so far.
Also the remove is working fine but I had to refresh the form
If any one has a suggestion or another idea, I will be thankful.
Thanks for your help
|
|
|
|
|
I have to make a program in Visual Basic .NET 2010 to manage a database in sql server. During the making process , i work with my database model :
Data Source=server1\SQLEXPRESS;Initial Catalog=udata1;Integrated Security=SSPI;
I create the entity framework model with this database through wizard process ( local database on my PC) and after i create the application connected with this database.The application work OK.
But i want to use this application with several databases on our network , and i want to make my final version of the program independent from database connection. So i want to put all the information for connecting with database on a text file .And when the application is starting should read the information from text file , create the connection and after do his normal operation. If something change , i want only to change the text file without touching the application. All the databases that i want to manage are identical with my first model that i use for creating application.
Maybe , this is not the right way , but i want to do. Can someone help me with this , or is impossible to do ?
Thank you !
|
|
|
|
|
You can do it and keep the connection string in a separate text file but do you really need it??
Better add a app.config file to your project and put the config settings there, you can make changes in the config and the App would read it from there...no need to recompile the project binaries.
hope it helps..
|
|
|
|
|
Thank you
But i have a app.config inside my project , this file was added when i have created the entity model through wizard.
My app.config is :
----------------
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" />
</startup>
<connectionStrings>
<add name="udataEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;
provider connection string=Data Source=server1\SQLEXPRESS;InitialCatalog=udata1;IntegratedSecurity=True;
MultipleActiveResultSets=True;Application Name=EntityFramework" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
-------------------
But what can i do now ?
Thank you.
|
|
|
|
|
Now once it's defined in the app.config you can use it in the code using ConfigurationManager.AppSettings.Get("udataEntities") and create a DB connection using either SqlClient or Enterprise Lib.
|
|
|
|
|
it's not clear for me , where i can use ConfigurationManager.AppSettings.Get("udataEntities")?
on the first form that is loaded , or .... ?
Can you explain to me , because until now on my application i never use connection string on my code , everything for connection is done by wizard when i have created entity model .
Thank you.
|
|
|
|
|
Yes..you can use it there but it's advisable not to connect the UI form directly to connect to DB.
Use a different class to keep all the db connection related code and call it from the UI in case it's a small project and you are not using client-server approach.
|
|
|
|
|
thank you !
But , if you have time , please give me some lines of code about what i should do.
Please !
Thank you.
|
|
|
|
|
This is how your app.config should look like:
="1.0"
<configuration>
<connectionStrings>
<add name="ConnectWithWinAuth" connectionString="Data Source=pshukla4;Initial Catalog=AdventureWorks;Persist Security Info=False;Trusted_Connection=Yes;" providerName="System.Data.SqlClient"/>
</connectionStrings>
<appSettings>
</appSettings>
</configuration>
The code in the calling method \ function should be something like this, I am using AdventureWorks DB that comes with SQL Server :
List<Dept> departments = new List<Dept>();
ConnectionStringSettings conString = ConfigurationManager.ConnectionStrings["ConnectWithWinAuth"];
using (SqlConnection con = new SqlConnection(conString.ConnectionString))
{
con.Open();
using (SqlCommand command = new SqlCommand("SELECT Name, GroupName FROM HumanResources.Department", con))
{
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
string name = reader.GetString(1);
string grpName = reader.GetString(2);
departments.Add(new Dept() { DeptId = deptId, Name = name, GroupName = grpName });
}
}
}
modified on Wednesday, September 7, 2011 7:00 PM
|
|
|
|
|
your app.config version , is compatible with entity frameworks model that i use ? because is different from my actual app.config file . Or is normal to change like in your version ?
|
|
|
|
|
No from App.config file only use the contents of ConnectioString tag...
|
|
|
|
|
In a nutshell you are best storing it in the app.config file. For further reading I would look at this CP article Storing Connection Strings[^]
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
|
|
|
|
|
how can i download and use msdn for vb6.0?
|
|
|
|
|
You can't.
Simple as that.
VB6 is unsupported, and Microsoft have abandoned it.
It is an orphan language.
You need to download VB.Net, the express edition is free.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
Hi Dalek,
I don't mean to be nit picky, but "VB6 is unsupported" is not entirely true. Please go to the following article posted by Microsoft that they are willing to support it to a certain extent. The article goes in depth as to what that extent is.
http://msdn.microsoft.com/en-us/vbasic/ms788708.aspx[^]
Cheers.
|
|
|
|
|
STOP THAT!!
If you keep bring that up, the damn thing will NEVER die!
Thankfully, that little document makes no menthion of Windows 8.
|
|
|
|
|
Your absolutely right. I will keep it a secret.
Haha.
|
|
|
|
|
You would need to have a subscription to MSDN Library as a minimum.
Then you would login to Subscription Services and download the October 2001 library ISO and install it to your computer. I am sure that is the last one that supported VB6 (i would have to dig out my old discs, as i remember writing it on it as a reminder to keep), and also see they have retained it online (just logged in to check)
Then in IDE you can then set the October 2001 library as the help files.......
|
|
|
|
|
Alternatively, OP could go for a more up to date language. In fact the last release of COBOL (2002) is more up to date then VB6 (1998)
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|