How to pass 'using' method as argument [Resolved]

Posted by Oswaldlily under ASP.NET on 2/15/2012 | Points: 10 | Views : 819 | Status : [Member] | Replies : 2
Step 1: In mapper .cs i have wrote following code
public string functionname(ref DataContext dc)
{



}

Step 2: In asp.cs (codebehind ) i have followin
using (DataContext Conn = new DataContext())
{

var obj=Mapper.functionname(ref Conn);



}



Error:Cannot pass 'Conn' as a argument or ref because it is a 'using' variable
in this line under 'Conn' getting red mark
var obj=Mapper.functionname(ref Conn);




Responses

Posted by: Blessyjees on: 2/22/2012 [Member] Bronze | Points: 50

Up
0
Down

Resolved
Hi,

Can you try this without "ref" in var obj=Mapper.functionname(ref Conn);

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hmanjarawala on: 2/22/2012 [Member] Bronze | Points: 25

Up
0
Down
Ok try this

Step 1: In mapper .cs i have wrote following code
public string functionname(ref DataContext dc)

{



}


Step 2: In asp.cs (codebehind ) i have followin
DataContext Conn=null;

using (Conn = new DataContext())
{

var obj=Mapper.functionname(ref Conn);



}


Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response