Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
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
 
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
 
Old August 20th, 2010, 10:36 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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!





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





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