Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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 November 10th, 2003, 09:07 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 146
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to aadz5
Default searching a datasource

Guys I am tring to search my data source. Everytime I press the button nothing is displayed. I have stored the textbox entries into string variables and then entered them into a select statement. and then used a dataset set filled it using the data adapter with the entries which were selected using the modified select statement and then display this in a datagrid. No result though. I think that it maybe due to how I store the textbox values. Here is my code: -

private void Button_Click(object sender, System.EventArgs e)
{
  String strAuthor = Author.Text;
  String strTitle = Title.Text;

  Connect();
  String strSearch = "SELECT Computing Where BookAuthor = " + strAuthor + " OR BookTitle =" + strTitle;
  OleDbDataAdapter objAdapter = new OleDbDataAdapter(strSQL, objConnection);
  DataSet ds = new DataSet();
  objAdapter.Fill(ds, "dtFilteredComputing");
  Disconnect();

  dgComputing.DataSource = ds.Tables[0].DefaultView;
  dgComputing.DataBind();
}

THanks

Adz

Adz - Portsmouth Massive
__________________
Adz - Learning The J2EE Ways.
 
Old November 10th, 2003, 09:42 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

You need to specify the table that you are pulling the data from.
Make:

SELECT Computing Where BookAuthor = "

something like:

SELECT Computing FROM [tablename] Where BookAuthor = "

J
 
Old November 10th, 2003, 09:54 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

I also noticed another possible problem in these two lines:

String strSearch = "SELECT Computing Where BookAuthor = " + strAuthor + " OR BookTitle =" + strTitle;

OleDbDataAdapter objAdapter = new OleDbDataAdapter(strSQL, objConnection);

Your SQL string is declared as "strSearch", but in the 2nd line you use "strSQL".

I don't use C#, but I assume the syntax should be pretty similar. I am also assuming that your connection has already been established because I don't see a connection string...

J
 
Old November 10th, 2003, 10:00 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

I think I see where you connect now. I believe that you call a Connect() and Disconnect() function, correct? Anyway, I hope those suggestions I gave help.

J
 
Old November 12th, 2003, 05:59 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 146
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to aadz5
Default

thanks but i have solved it

Adz

Adz - Portsmouth Massive





Similar Threads
Thread Thread Starter Forum Replies Last Post
DataSource suhas_feb BOOK: Professional Jakarta Struts 1 June 19th, 2007 09:46 PM
Object datasource VS DataSource SoftMind BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 4 July 27th, 2006 10:44 PM
ListBox DataSource jugomkd C# 2 October 9th, 2004 11:30 PM
DataSource, Oracle... mali djuro JSP Basics 0 October 20th, 2003 07:51 AM
DataSource keseln J2EE 1 June 8th, 2003 08:45 PM





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