Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Value of type 'String' cannot be converted to '1-dimensional array of String'

Posted on 2007-03-23
1
Medium Priority
?
1,088 Views
Last Modified: 2008-01-09
I want to pass string values from my listbox to a function which is located in another file, I get an error when i try to pass values in
AddUsersToRoles()

Please Advice:

        Dim lstItem As ListItem
        For Each SelectedItem In CType(SelectRoles.FindControl("AvailableRoles"), ListBox).Items
            If lstItem .Selected = True Then
                MyRole= lstItem .Value
                System.Web.Security.Roles.AddUsersToRoles(CreateUserWizard1.UserName, MyRole)
            End If
        Next

Error: Value of type 'String' cannot be converted to '1-dimensional array of String'
this errors is in: AddUsersToRoles(CreateUserWizard1.UserName, MyRole)

AddUsersToRoles Object Browswer:
Public Shared Sub AddUsersToRoles(ByVal usernames() As String, ByVal roleNames() As String)
     Member of: System.Web.Security.Roles
Summary:
Adds the specified users to the specified roles.

Parameters:
roleNames: A string array of role names to add the specified user names to.
usernames: A string array of user names to add to the specified roles.

Exceptions:
System.Configuration.Provider.ProviderException: Role management is not enabled.
System.ArgumentNullException: One of the roles in roleNames is null.-or-One of the users in usernames is null.
System.ArgumentException: One of the roles in roleNames is an empty string or contains a comma (,).-or-One of the users in usernames is an empty string or contains a comma (,).-or-roleNames contains a duplicate element.-or-usernames contains a duplicate element.

0
Comment
Question by:Padre_Corleone
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 15

Accepted Solution

by:
Thogek earned 2000 total points
ID: 18784538
It sounds like both parameters of the System.Web.Security.Roles.AddUsersToRoles method are arrays (see http://msdn2.microsoft.com/en-us/library/system.web.security.roles.adduserstoroles(VS.80).aspx), but you're trying to pass it single objects instead of arrays, so it's complaining that it can't convert them for you.

You could patch the difference with something like:

    System.Web.Security.Roles.AddUsersToRoles(New String() { CreateUserWizard1.UserName}, New String() { MyRole })
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question