I am new to asp.net and I am trying to implement my role provider, actually sql role provider. In my Role Provider I added:
public void AddUsersToRole(string[] usernames, string[] rolenames)
{
SqlConnection conn =
new SqlConnection(
ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString);
SqlCommand cmd = new SqlCommand("INSERT INTO Users " +
" (Username, Role) " +
" Values(?, ?)", conn);
SqlParameter Username = cmd.Parameters.Add("@Username", SqlDbType.NVarChar, 50);
SqlParameter Role = cmd.Parameters.Add("@Role", SqlDbType.NVarChar, 50);
try
{
conn.Open();
foreach (string username in usernames)
{
foreach (string rolename in rolenames)
{
Username.Value = username;
Role.Value = rolename;
cmd.ExecuteNonQuery();
}
}
}
But when I put in my login page the following:
Roles.AddUsersToRole(TextBoxUsername.Text, DropDownListRole.SelectedItem.Value);
And when I build it I got an error.
Please help, tnx in advance.
your method expecting
string[]
but you are providingstring
.solution: