Solved

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

Posted on 2010-09-19
12
2,789 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 500 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
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!

 
LVL 10

Assisted Solution

by:himanshut
himanshut earned 500 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 500 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 500 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

726 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