Solved

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

Posted on 2010-09-19
12
2,478 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
 
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now