How to import "using system.data.oledb;" automatically - C Sharp 2005
-
Dear, Every new form, I've to import using system.data.oledb. Is there anyways to make it default every new form? Thanks,
Chuon Visoth Angkor Wat - Cambodia asp.net - c sharp beginner
Hi, you cannot "import" the using statement automatically. But if you access everthing full qualified (e.g. System.Data.OleDb.DbConnection...) you don't need the using statement. Don't know if I get your question right. The using-statement is just something like "syntactic sugar". It is just there to access classes within a namespace without using the fully qualified method. It is nothing like an "import". Regards Sebastian
It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.
-
Hi, you cannot "import" the using statement automatically. But if you access everthing full qualified (e.g. System.Data.OleDb.DbConnection...) you don't need the using statement. Don't know if I get your question right. The using-statement is just something like "syntactic sugar". It is just there to access classes within a namespace without using the fully qualified method. It is nothing like an "import". Regards Sebastian
It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.
-
Dear, Every new form, I've to import using system.data.oledb. Is there anyways to make it default every new form? Thanks,
Chuon Visoth Angkor Wat - Cambodia asp.net - c sharp beginner
Yup :) You can create "project" and "item" templates for re-use. Create a new project, add your references and choose "File", "Export Template". Export the project-template, and it will appear under "File/New" once you put it in the "\Templates" folder of Visual Studio (see "My Documents") If you only want a form, and not a complete project, then add the using and start the export-wizard again. Select your form, export as a template and save the generated template under "My Documents\Visual Studio 2008\Templates\ItemTemplates\Visual C#"
I are Troll :)
-
Dear, Every new form, I've to import using system.data.oledb. Is there anyways to make it default every new form? Thanks,
Chuon Visoth Angkor Wat - Cambodia asp.net - c sharp beginner
Yes, but you have to either provide your own template or modify the MS ones. Your own is easy: create an example of the form you want, and save it as a template in "My Documents\Visual Studio 2008\Templates\ItemTemplates\Visual C#" Modifying the MS ones is also easy, but back them up first! Go to "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplatesCache\CSharp\Windows Forms\1033\Form.zip" and edit the the form.cs file. Add your using statements and save. Add...new...Windows Form will now include your stuff.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones
-
Dear, Every new form, I've to import using system.data.oledb. Is there anyways to make it default every new form? Thanks,
Chuon Visoth Angkor Wat - Cambodia asp.net - c sharp beginner
The other answers are correct, but... your Form should not be accessing the database directly; write (at least) a Data Access Layer and then access that from your form.