• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3339
  • Last Modified:

'System.Data.SqlClient.SqlConnection' does not contain a definition

Error      10      'System.Data.SqlClient.SqlConnection' does not contain a definition for 'ExecuteQuery' and no extension method 'ExecuteQuery' accepting a first argument of type 'System.Data.SqlClient.SqlConnection' could be found (are you missing a using directive or an assembly reference?)      C:\inetpub\wwwroot\OmegaLove.Web\OmegaLove.Web\Controls\UniGrid.ascx.cs      583      26      OmegaLove.Web
 

SqlConnection con = new SqlConnection();
                con.ConnectionString = ConfigurationManager.ConnectionStrings["omegaloveConnectionString"].ConnectionString;

                ds = con.ExecuteQuery(this.Query, this.QueryParameters, this.CompleteWhereCondition, this.OrderBy);
0
omegalove
Asked:
omegalove
  • 8
  • 4
4 Solutions
 
himanshutCommented:
you need to open connection I guess :)

0
 
omegaloveAuthor Commented:
Command cmd =
con.open?

con.close?

 // Reload the data with current parameters
                SqlConnection con = new SqlConnection();
                con.ConnectionString = ConfigurationManager.ConnectionStrings["omegaloveConnectionString"].ConnectionString;
               
                ds = con.ExecuteQuery(this.Query, this.QueryParameters, this.CompleteWhereCondition, this.OrderBy);

I don't have the syntax.
0
 
omegaloveAuthor Commented:
hello?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
himanshutCommented:
SqlConnection con = new SqlConnection();
                con.ConnectionString = ConfigurationManager.ConnectionStrings["omegaloveConnectionString"].ConnectionString;
               con.ConnectionString.Open()

                ds = con.ExecuteQuery(this.Query, this.QueryParameters, this.CompleteWhereCondition, this.OrderBy);
con.ConnectionString.Close()
0
 
omegaloveAuthor Commented:
con.ConnectionString.Open()

does not contain definion for Open and Close?
0
 
himanshutCommented:
did u add System.Data.SqlClient namespace on top of the page?

It looks like you didn't add the SqlClient namespace where you have other namespaces like System.Data, etc
0
 
omegaloveAuthor Commented:
con.ConnectionString.Open()
I have the namespace.
0
 
omegaloveAuthor Commented:
Still does not work.
0
 
omegaloveAuthor Commented:
SqlConnection con = new SqlConnection();
                con.ConnectionString = ConfigurationManager.ConnectionStrings["omegaloveConnectionString"].ConnectionString;
                con.Open();
                ds = con.ExecuteQuery(this.Query, this.QueryParameters, this.CompleteWhereCondition, this.OrderBy);
                con.Close();

Error      16      'System.Data.SqlClient.SqlConnection' does not contain a definition for 'ExecuteQuery' and no extension method 'ExecuteQuery' accepting a first argument of type 'System.Data.SqlClient.SqlConnection' could be found (are you missing a using directive or an assembly reference?)      C:\inetpub\wwwroot\OmegaLove.Web\OmegaLove.Web\Controls\UniGrid.ascx.cs      596      26      OmegaLove.Web
0
 
himanshutCommented:
check the example here:

http://msdn.microsoft.com/en-us/library/dw70f090%28VS.80%29.aspx

you need to have :

1. ConnectionString
2. query or Command
3. Connection Open
4. DataReader
5. ExecuteReader
6. Connection Close

In your code I can't see any Datareader, you are just having connection strings, which you open but to execute the query/command you need to have datareader. Refer to the link I sent you

Cheers!
0
 
omegaloveAuthor Commented:
u lost me.
 public void ReloadData()
        {
            DataSet ds = null;

            // if datasource for unigrid is query (not dataset), then execute query
            if ((this.Query != null) && (this.Query != string.Empty))
            {
                // Reload the data with current parameters
                SqlConnection con = new SqlConnection();
                con.ConnectionString = ConfigurationManager.ConnectionStrings["omegaloveConnectionString"].ConnectionString;
                con.Open();
              //  ds = con.ExecuteQuery(this.Query, this.QueryParameters, this.CompleteWhereCondition, this.OrderBy);
                con.Close();

            }
            // external dataset is used
            else
            {
                if (this.OnDataReload != null)
                {
                    ds = OnDataReload(CompleteWhereCondition);
                }
                else
                {
                    ds = (DataSet)(this.DataSource);
                }
            }
0
 
omegaloveAuthor Commented:
k
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 8
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now