Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 5th, 2006, 04:25 PM
Registered User
 
Join Date: Dec 2006
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default SqlDataAdapter does not have its properties

I tried to use some of the properties of SqlDataAdapter e.g. SelectCommand, Fill, etc. I don't see these properties listed in VS 2005 intellisense.

Reply With Quote
  #2 (permalink)  
Old December 5th, 2006, 05:22 PM
Friend of Wrox
 
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

show your code.

Woody Z
http://www.learntoprogramnow.com
Reply With Quote
  #3 (permalink)  
Old December 5th, 2006, 05:41 PM
Registered User
 
Join Date: Dec 2006
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here's the code:

SqlConnection MyConnection;
            SqlCommand MyCommand;
            SqlDataAdapter MyAdapter;
            DataTable MyTable = new DataTable();

            MyConnection = new SqlConnection();
            // MyConnection.ConnectionString = "server= E901872; Trusted_Connection= yes; database= AdventureWorks"; //This works too.
            MyConnection.ConnectionString = "Data Source= E901872; Initial Catalog= AdventureWorks; Integrated Security=True";
            // ConfigurationManager.ConnectionStrings["DSN_Northwind"].ConnectionString;

            MyCommand = new SqlCommand();
            MyCommand.CommandText = " SELECT TOP 5 * FROM Person.Contact ";
            MyCommand.CommandType = CommandType.Text;
            MyCommand.Connection = MyConnection;

// MyCommand.Connection.Open(); // Don't have to call this, copied this from Default.aspx.cs
            MyAdapter = new SqlDataAdapter();
            MyAdapter.SelectCommand = MyCommand;
            MyAdapter.Fill(MyTable);

            GridView1.DataSource = MyTable.DefaultView;
            GridView1.DataBind();

            MyAdapter.Dispose();
            MyCommand.Dispose();
            MyConnection.Dispose();

Reply With Quote
  #4 (permalink)  
Old December 5th, 2006, 05:57 PM
Friend of Wrox
 
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Everything looks fine regarding the SqlDataAdapter.

I assume you are getting intellisense on the other SqlClient objects such as the SqlCommand?

Does your code run?



Woody Z
http://www.learntoprogramnow.com
Reply With Quote
  #5 (permalink)  
Old December 5th, 2006, 06:38 PM
Registered User
 
Join Date: Dec 2006
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I see other properties and methods of the SqlDataAdapter class as well as all that of the SqlCommand in intellisense.

The code does not compile. It has the following errors:

Error 1 'SqlDataAdapter' does not contain a definition for 'SelectCommand'
Error 2 'SqlDataAdapter' does not contain a definition for 'Fill'

Reply With Quote
  #6 (permalink)  
Old December 5th, 2006, 07:35 PM
Friend of Wrox
 
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What other properties and methods are available on the MyAdapter object?

This is not a typical problem. If the other expected methods of the SqlDataAdapter are available, then something odd is going on. What Using statements have you used in the code - could you please show those?

Woody Z
http://www.learntoprogramnow.com
Reply With Quote
  #7 (permalink)  
Old December 6th, 2006, 11:42 AM
Registered User
 
Join Date: Dec 2006
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, I think there's something odd going on. This seems to be not a typical problem. In intellisense, I was able to see all of the properties and methods of the MyAdapter object except for the properties like SelectCommand, InsertCommand, UpdateCommand, and DeleteCommand. When I select to add the references, I see the System.Data.SqlClient.dll having a different version and a different path from the rest of other System namespaces on my pc.

Here's the Using statements I used in the code:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Data.Common;
using System.Data.SqlClient;

Thank you for your responds.

Reply With Quote
  #8 (permalink)  
Old December 6th, 2006, 12:07 PM
Friend of Wrox
 
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Your using statements all appear to be correct.
Another question:
Are you referencing the System.Data.SqlClient.dll directly? I don't see how you could be doing this without being aware of it.
However, if you are doing this, it is possible that is causing the problem.






Woody Z
http://www.learntoprogramnow.com
Reply With Quote
  #9 (permalink)  
Old December 6th, 2006, 12:43 PM
Registered User
 
Join Date: Dec 2006
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don't know what you mean by referencing the System.Data.SqlClient.dll directly.
I just tried to fix the problem by looking at the add references list.

Thanks.

Reply With Quote
  #10 (permalink)  
Old December 6th, 2006, 12:46 PM
Friend of Wrox
 
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In the solution explorer each project has a References folder - this folder has a list of all the references set for the project. Do you have a listing for System.Data.SqlClient, or just System.Data. You should not have one for System.Data.SqlClient - and this is what I want to check.

Woody Z
http://www.learntoprogramnow.com
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sqldataadapter vgsgowrisankar C# 2005 7 April 23rd, 2008 04:32 PM
SqlDataAdapter DanRoche .NET Framework 1.x 3 August 20th, 2007 04:04 AM
SqlDataAdapter does not have its properties listed thaopham215 ADO.NET 0 December 5th, 2006 04:33 PM
SqlDataAdapter Issue Tom Wing VB.NET 2002/2003 Basics 2 February 6th, 2006 01:43 PM
sqlDataAdapter webguy@rocketmail.com ADO.NET 1 April 8th, 2004 12:28 AM



All times are GMT -4. The time now is 06:20 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.