'MultipleActiveResultsSets' Keyword Not Supported
Asked Answered
T

6

9

I am trying to read from an SQL Server database which is hosted on MS Azure, through an ASP.NET WebForms website created in Visual Studio 2013.

I've stored the Connection String in Web.Config, and have referenced it in my Code-Behind.

However, when I try to run Default.aspx locally, this error is displayed.

Here is my Web.Config:

  <connectionStrings>
     <add name="FYPConnectionString1" 
     connectionString="Data Source=damo.database.windows.net‌​;Initial Catalog=Ballinora_db;         
     Persist Security Info=True; User ID={Username};Password={Password};" />
  </connectionStrings>

I removed "MultipleActiveResultsSets=False" from the Connection String to see if the error stopped, but instead, the error now displays for "Encrypt".

So the error is appearing for the next item after the Password part of the connection string. Would the password have anything to do with the problem?

Also, this username and password which are required, are they the Server Admin Login details which appear in the Azure portal?

Here is the Code-Behind also:

private void bindRepeater()
{
    string constr = ConfigurationManager.ConnectionStrings["FYPConnectionString1"].ConnectionString;  
    //-- assuming Azure connection string stored in ConnectionString config in Web.Config as YourConnString 
    using (SqlConnection con = new SqlConnection(constr))
    {
        using (SqlCommand cmd = new SqlCommand("SELECT Name FROM Users", con))
        {
            cmd.CommandType = CommandType.Text;
            con.Open();
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            sda.Fill(dt);
            repTest.DataSource = dt;
            repTest.DataBind();
            con.Close();
        }
    }
}

protected void btnDisplay_Click(object sender, EventArgs e)
{
    this.bindRepeater();
}
Thermal answered 15/2, 2017 at 11:33 Comment(2)
Hello, I also use Azure Cloud Server with SQL Database. I updated my answer. And please refer to the 'Related' in the right of this question post. There're some similar cases with you. Here're also the links. 1) #1404768 2) #9237054Depository
3) #41648001 4) #33600353 5) #41484266Depository
O
13

You mistyped "MultipleActiveResultsSets". The "Result" in it is not plural.

Correct way: "MultipleActiveResultSets".

Oculo answered 13/2, 2018 at 15:0 Comment(1)
This worked for me. I had used "Set" instead of "Sets".Doxy
E
4

Note for others finding this question: This can also happen if you forget to choose the proper Type (data provider) in the Azure configuration for the connection string. It happened for me with MySQL selected instead of SQLAzure. Since the keyword isn't on that provider it causes an error.

enter image description here

Engracia answered 26/6, 2020 at 15:55 Comment(0)
D
0

The default value of MultipleActiveRe‌​‌​sultSets is False.

And if you don't need the function, just get out (delete) ' MultipleActiveRe‌​‌​sultSets=False ' of connectionstring.

Because the default value is false. If you want false, you don't need to write it by intention.

We need the function of MultipleActiveRe‌​‌​sultSets as we open second SQL connection inside while loop of SqlDataReader of the first SQL connection.

However, why ' MultipleActiveRe‌​‌​sultSets=False ' is recognized as wrong syntax is still question.

Update-

That's why I was curious why it was wrong. I think the syntax for MultipleActiveRe‌​‌​sultSets and Encrypt don't have problem.

Here is my connectionString in Web.Config:

<connectionStrings>
     <add name="GreenLeaf"  connectionString="Server=tcp:greentree.database.secure.windows.net,1433;Database=greentea;User ID=greenusers@greentree;Password=abc123;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;MultipleActiveResultSets=True;"/>
</connectionStrings>

The differences with yours are,

1) tcp 2) secure 3) @greentree (the Servername greentree together with ID like (greenusers@greentree) 4) without provider

'secure' is new feature that Azure automatically provide secure connection and you can find about this on internet.

Check the firewall of Server and just try to give a shot with above points.

Using the admin ID is correct but in aspect of security, you need to create additional Login and User for external users with limited roles and permissions.

Can you connect to Azure Server(Database) through Azure Portal? Visual Studio? Server Management Studio?

When you enter Server Management Studio, in the pop-up for connection, there's 'Server Name'. Input 'greentree.database.windows.net' there and try to login with your admin credentials.

Or can you connect to Azure Server without connectionString in Web.Config but in plain code?

And if possible, please update with the screencapture of exception, not the text only.

And for last, I'm sure you know very well, we're needed to encrypt the connectionString later for security.

Depository answered 15/2, 2017 at 15:4 Comment(4)
Hi @Kay Lee, I removed MultipleActiveResultSets=False from the connection string, but then the same error still appears. However, this time it is for Encrypt. So for some reason, this error is occuring after the Password within the Connection String. Does that give any extra information?Thermal
Hi, I will now update my connection string to look like yours above to see if that works. I can log into my database in SQL Server Management Studio with an SQL Server Authentication login. But when I put these same login details into my connection string I get that errorThermal
Ok, utilize the connectionString which is automatically generated by Visual Stuio or Server Management Studio. And take a look at similar cases.Depository
Does your password contain any symbols that might get in conflict with the connection and should be masked? Thinking about ; or " or sth like that.Kezer
N
0

I also had this problem. For me the password that I had created contained a semicolon and the password was leaking into the next part of the connection string.

I removed the semicolon in the password and it worked.

Eg the end of the password was "j;.&6". The error I was getting was

"- $exception {"Keyword not supported: '**.&6;**multipleactiveresultsets'."} System.ArgumentException"

Numbles answered 4/10, 2021 at 3:53 Comment(0)
L
0

in my case i deleted

MultipleActiveRe‌​‌​sultSets=True

from connectionString in web.config

and its work fine.

Licking answered 15/3, 2023 at 6:58 Comment(0)
D
0

In my case had the string

multiple active result sets=True

been added in addition to the correct string

MultipleActiveResultSets=True

This happened in a .NET 4.8 project while using Visual Studio 2022 when changing server from production name to localhost with the help of the Update wizardUpdate Wizard

I solved it by removing multiple active result sets=True from App.config/Web.config.

Darya answered 12/6, 2023 at 5:47 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.