Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Professional ASP.NET 4 : in C# and VB
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: Professional ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Professional ASP.NET 4 in C# and VB by Bill Evjen, Scott Hanselman, Devin Rader; ISBN: 9780470502204
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET 4 : in C# and VB 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
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 20th, 2010, 06:25 AM
Registered User
 
Join Date: Aug 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Data Adapter Problems????????

DataTable MyTable = new DataTable();
SqlConnection Conn;
Conn = new SqlConnection(@"Data Source=179-RAKESHP\SQLEXPRESS;Initial Catalog=School;Integrated Security=True;User Instance=True");
Conn.Open();
SqlParameter Countryparam;
SqlCommand MyCommand = new SqlCommand();
MyCommand.CommandText = "SELECT State FROM Table_1 WHERE Country=@Country";
MyCommand.CommandType = CommandType.Text;
MyCommand.Connection = Conn;
SqlDataAdapter MyAdapter= new SqlDataAdapter();
MyAdapter.SelectCommand = MyCommand;
Countryparam = new SqlParameter();
Countryparam.Direction = ParameterDirection.Output;
Countryparam.Value = TextBox8.Text;
DropDownList1.Text = MyCommand.CommandText;
MyAdapter.Fill(MyTable);
DropDownList1.DataSource = MyTable.DefaultView;
DropDownList1.DataBind();
MyCommand.Dispose();
Conn.Dispose();

//I have tried to make a normal connection to Sql Server2008 database by taking the input from a textbox and using it as a parameter for retrieving the data From a tale in database and i wanted to display it in one of my d.down box.........the idea is that if user enters country name,he gets the options of existing states..............can someone please help me get a runnable code........plzzzz
  #2 (permalink)  
Old August 20th, 2010, 06:29 AM
Registered User
 
Join Date: Aug 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Red face

actually im new to asp.net and c#....hope i don't annoy professional programmers by asking a silly question
  #3 (permalink)  
Old August 20th, 2010, 10:36 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Quote:
hope i don't annoy professional programmers by asking a silly question
In that case, you're better off posting in the general ASP.NET 4 Basics or other forum, as your question may be ignored here.

That said, you're creating a Parameter instance but never add it to the Parameters collection of the Command object.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 


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
how to update data source using data adapter Rohit Kapoor BOOK: Visual Basic 2008 Programmer's Reference ISBN: 978-0-470-18262-8 0 January 15th, 2009 06:16 AM
how to update data source using data adapter Rohit Kapoor All Other Wrox Books 0 January 15th, 2009 06:05 AM
problems configuring smtp adapter shazza Biztalk 0 August 20th, 2007 06:57 PM
Data Adapter k_kosaraju ADO.NET 1 October 31st, 2004 09:51 AM



All times are GMT -4. The time now is 12:07 AM.


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