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
Solved

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

Posted on 2010-09-19
12
2,697 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
  • 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…

789 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