|
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
|
|
|
|
|
|
WOW the background on that site is "horrible" My eyes are tearing up from the pain
Frazzle the name say's it all
|
|
|
|
|
Forget VB6.0. Download Visual Studio 2010 from microsoft[^].
|
|
|
|
|
The best way to that I am aware of is to go the msdn website to get all Visual Studio 6.0 related references. As to actually downloading it I am unaware of doing it unless you are able to obtain the msdn cd from someone.
http://msdn.microsoft.com/en-us/library/ms950417.aspx[^]
|
|
|
|
|
In a ToolStripDropDownButton, the check marks in the menu items are misaligned to the top, and the area in the left margin of each menu item (where the check marks are drawn) overlaps the text portion of the menu item. The check marks are also quite small.
Originally the ToolStrip's ImageScalingSize was 16x16. I've since changed it to 32x32 and changed out all the images. The only way the menu items render properly is if I change the ImageScalingSize back to 16x16. Here's a screen capture of the menu: Click[^]
How do I get the check marks to render properly?
XAlan Burkhart
|
|
|
|
|
Finally found a solution. It does not address why it happened, but it does cause the check marks to display as they should. My code below was adapted from this MSDN article[^].
CType(tb_Options.DropDown, ToolStripDropDownMenu).ShowImageMargin = False
CType(tb_Options.DropDown, ToolStripDropDownMenu).ShowCheckMargin = True
And if anyone knows why this might happen (never saw it before), feel free to chime in with my thanks.
XAlan Burkhart
|
|
|
|
|
Hey peepz,
After a big torture of searching i came 2 my last hope.
Situation :
I have a mdiparent where i open mdichild A. From mdichild A, i click a button to open mdichild B.
I "simply" want to pass a value from mdichild B to mdichild A(not a new form).
Question:
How can i get a value from form B to retreive this in form A(bouth mdichilds).
form.show =>opens a new form
dim formbla as new blabla =>opens also a new form
already tried a less best practice :
formA.lblDate.Text = DataGridView1.Item(9, i).Value.ToString()
but this only works when i use the show method...
I'm begging 4 help
Somebody?
Thx in advance
|
|
|
|
|
Have a read of these
Step by Step: Event handling in VB.NET[^]
Delegates[^]
and choose which one that best suits your needs
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
|
|
|
|
|
You could create a public method on formb that returns the value you want. Then call it from forma.
|
|
|
|
|
Hey,
First of all thx for the reply,reallllly appreciate that
Second my apologizes if i'm working on your nerve system.
I'm an advanced noob with vb.net
But can somebody explain it with some example's?
I checked the event tutorial but there must be a faster way no?(don't like to add classes for a single transport).
So i like the public method more, but can you show me an example how i should write the method in form b and how to access my values in form a?
Thanks again
|
|
|
|