Click here to Skip to main content
12,689,777 members (25,381 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#
I need help with the below code I would like to generate it using CodeDom in C#.
Is there any way to do this?
If there is no way to do this in CodeDom is the any alternative way beside using statement?
using (SqlConnection con1 = new SqlConnection(Core.ConnectionStringSample))
                using (SqlCommand cmd = con1.CreateCommand())

Posted 17-Dec-12 0:34am
Updated 17-Dec-12 5:54am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I'm not particularly familiar with CodeDom, but a using statement can be rewritten using try-finally, for example:

(SqlConnection con1 = new SqlConnection(Core.ConnectionStringSample))
    // code

can be written as:

SqlConnection con1 = new SqlConnection(Core.ConnectionStringSample);
    // code
    if (con1 != null)
drake24 19-Dec-12 5:44am
thank you mr. lewax00 for your answer i will try the try finally catch statement to replace the using statement.

To others who have a solution i'll gladly accept and try yours.
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170113.4 | Last Updated 17 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100