Login    Forum    Search    FAQ   Blog

Board index » Server Side Development » ASP 3.0




 Page 1 of 1 [ 4 posts ] 



Author Message
 Post subject: help convertin vb 2 c#
 Post Posted: Sun Nov 22, 2009 2:37 pm 
Offline

Joined: Sat Feb 21, 2009 3:16 pm
Posts: 46
I m havin the following code dat I tried 2 convert 2 C# nd it does
not workd:

VB Code:

Code:
    Protected Sub sqlItemInsertIntoParts_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs)
        e.Command.Parameters("@PartsUserId").Value = Membership.GetUser().ProviderUserKey
    End Sub   



Using an online converter it converted to the following C# code:

Code:
protected void sqlItemInsertIntoParts_Inserting(object sender, System.Web.UI.WebControls.SqlDataSourceCommandEventArgs e)
    {
        e.Command.Parameters("@PartsUserId").Value = Membership.GetUser().ProviderUserKey;
    }



When I try 2 run da page, I m gettin the followin error:

Compiler Error Message: CS1955: Non-invocable member 'System.Data.Common.DbCommand.Parameters' cannot be used like a method.

Source Error:
Code:


Line 28:     protected void sqlItemInsertIntoParts_Inserting(object sender, System.Web.UI.WebControls.SqlDataSourceCommandEventArgs e)
Line 29:     {
Line 30:         e.Command.Parameters("@PartsUserId").Value = Membership.GetUser().ProviderUserKey;
Line 31:     }
Line 32:



could sumone show me what da convertd code would look like?



Thanks


Top 
 Post subject: Re: help convertin vb 2 c#
 Post Posted: Sun Nov 22, 2009 2:37 pm 
Offline

Joined: Sat Feb 21, 2009 11:06 am
Posts: 1794
Try:

Code:
    protected void sqlItemInsertIntoParts_Inserting(object sender, System.Web.UI.WebControls.SqlDataSourceCommandEventArgs e)
    {
        e.Command.Parameters["@PartsUserId"].Value = Membership.GetUser().ProviderUserKey;
    }


c# uses square brackets 4 the arrays, indexers nd attributes.


Top 
 Post subject: Re: help convertin vb 2 c#
 Post Posted: Sun Nov 22, 2009 2:37 pm 
Offline

Joined: Sat Feb 21, 2009 1:08 pm
Posts: 549
Hi,
In VB ( ) brackets r used 4 index nd in c# [ ] brackets r used 4
index.

Code:
e.Command.Parameters ["@PartsUserId"].Value = Membership.GetUser().ProviderUserKey;


Top 
 Post subject: Re: help convertin vb 2 c#
 Post Posted: Sun Nov 22, 2009 2:37 pm 
Offline

Joined: Sat Feb 21, 2009 3:16 pm
Posts: 46
..


Top 
Display posts from previous:  Sort by  
 
 Page 1 of 1 [ 4 posts ] 




Board index » Server Side Development » ASP 3.0


Who is online

Users browsing this forum: No registered users and 1 guest

 
 

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron