?
Solved

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

Posted on 2010-09-19
12
Medium Priority
?
3,041 Views
Last Modified: 2012-05-10
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
Comment
Question by:omegalove
[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
  • 8
  • 4
12 Comments
 
LVL 10

Accepted Solution

by:
himanshut earned 2000 total points
ID: 33712909
you need to open connection I guess :)

0
 

Author Comment

by:omegalove
ID: 33712994
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
 

Author Comment

by:omegalove
ID: 33713137
hello?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 10

Assisted Solution

by:himanshut
himanshut earned 2000 total points
ID: 33713273
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
 

Author Comment

by:omegalove
ID: 33713365
con.ConnectionString.Open()

does not contain definion for Open and Close?
0
 
LVL 10

Assisted Solution

by:himanshut
himanshut earned 2000 total points
ID: 33713472
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
 

Author Comment

by:omegalove
ID: 33713550
con.ConnectionString.Open()
I have the namespace.
0
 

Author Comment

by:omegalove
ID: 33713553
Still does not work.
0
 

Author Comment

by:omegalove
ID: 33713564
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
 
LVL 10

Assisted Solution

by:himanshut
himanshut earned 2000 total points
ID: 33713631
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
 

Author Comment

by:omegalove
ID: 33721478
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
 

Author Closing Comment

by:omegalove
ID: 33762977
k
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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

765 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