Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Re: System.Net.Sockets.SocketException: A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied
Please Help for solving this error

This is my code
C++
public DataSet ExecuteDataset(string connectionString, CommandType commandType, string commandText)
       {
           DataSet ds = new DataSet();
           using (MySqlConnection cn = new MySqlConnection(connectionString))
           {
               MySqlCommand cmd = new MySqlCommand(commandText, cn);
               MySqlDataAdapter da = new MySqlDataAdapter(cmd);

               try
               {
                   da.Fill(ds);
               }
               catch (Exception ex)
               {
                   errorDescription = ex.Message.ToString().Replace("\n", "");
                   string s = errorDescription.Substring(0, 6);
                   if (errorDescription.Substring(0, 6) == "#42000")
                   {
                       MySqlCommand cmd1 = new MySqlCommand("SET SQL_BIG_SELECTS = 1", cn);
                       try
                       {
                           cn.Open();
                           cmd1.ExecuteNonQuery();
                           da.Fill(ds);
                       }
                       catch (Exception)
                       {
                           errorDescription = ex.Message.ToString().Replace("\n", "");
                           SendToErrorPage(errorDescription);
                       }
                       finally
                       {
                           cmd1.Parameters.Clear();
                           cmd1.Dispose();
                           cn.Close();
                       }
                   }
                   else
                   {
                       SendToErrorPage(errorDescription);
                   }
               }
               finally
               {
                   cmd.Parameters.Clear();
                   cmd.Dispose();
                   cn.Dispose();
               }
           }
           replaceCorrectValues(ds);
           return ds;

           }


It open connection and executed the query very well but fail at time of filling data in dataset and gives posted error.
Posted
Updated 20-Sep-13 3:13am
v2
Comments
[no name] 20-Sep-13 6:17am    
Provide the code snippet...
Tausif/Pintu 20-Sep-13 6:23am    
This is my code
public DataSet ExecuteDataset(string connectionString, CommandType commandType, string commandText)
{
DataSet ds = new DataSet();
using (MySqlConnection cn = new MySqlConnection(connectionString))
{
MySqlCommand cmd = new MySqlCommand(commandText, cn);
MySqlDataAdapter da = new MySqlDataAdapter(cmd);

try
{
da.Fill(ds);
}
catch (Exception ex)
{
errorDescription = ex.Message.ToString().Replace("\n", "");
string s = errorDescription.Substring(0, 6);
if (errorDescription.Substring(0, 6) == "#42000")
{
MySqlCommand cmd1 = new MySqlCommand("SET SQL_BIG_SELECTS = 1", cn);
try
{
cn.Open();
cmd1.ExecuteNonQuery();
da.Fill(ds);
}
catch (Exception)
{
errorDescription = ex.Message.ToString().Replace("\n", "");
SendToErrorPage(errorDescription);
}
finally
{
cmd1.Parameters.Clear();
cmd1.Dispose();
cn.Close();
}
}
else
{
SendToErrorPage(errorDescription);
}
}
finally
{
cmd.Parameters.Clear();
cmd.Dispose();
cn.Dispose();
}
}
replaceCorrectValues(ds);
return ds;

}

It open connection and executed the query very well but fail at time of filling data in dataset and gives posted error.
Joan M 20-Sep-13 9:14am    
I've done this for you, but you can always improve your own question by clicking on the Green "Improve question" link under your post. When pasting code then you can use the CODE blocks. ;)
phil.o 20-Sep-13 9:38am    
Which line throws the exception?
Tausif/Pintu 23-Sep-13 3:21am    
Thanks for reply, There was problem in connection string, It required port number of hosting, I solved this problem.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900