How to make this SQL SELECT statement work in ASP.NET

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2004
Posts: 38
Reputation: mindfrost82 is an unknown quantity at this point 
Solved Threads: 0
mindfrost82 mindfrost82 is offline Offline
Light Poster

How to make this SQL SELECT statement work in ASP.NET

 
0
  #1
Jun 11th, 2008
Can someone help me convert this SQL SELECT statement to ASP.NET code (if possible):

  1. SELECT * FROM tblCategory RIGHT JOIN tblInventory ON tblCategory.categoryID = tblInventory.categoryID
  2. WHERE (((tblInventory.type)=[strSearch])) OR (((tblInventory.country)=[strSearch])) OR (((tblInventory.date)=[strSearch])) OR (((tblInventory.eventSeries)=[strSearch])) OR (((tblInventory.grade)=[strSearch])) OR (((tblInventory.comment)=[strSearch]));

I'm trying to use it as a SelectCommand.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 291
Reputation: ericstenson is an unknown quantity at this point 
Solved Threads: 29
Team Colleague
ericstenson's Avatar
ericstenson ericstenson is offline Offline
Posting Whiz in Training

Re: How to make this SQL SELECT statement work in ASP.NET

 
0
  #2
Jun 11th, 2008
  1. Dim conn1 as new data.sqlclient.sqlconnection(CONNECTIONSTRING)
  2. Dim Select_String as String = WHAT YOU JUST WROTE
  3. Dim Select_Adapter as new data.sqlclient.sqldataadapter(Select_String,conn1)
  4. Dim YourDataSet as New Data.Dataset
  5. conn1.open
  6. Select_Adapter.Fill(YourDataSet)
  7. conn1.close

There are free converters to C# if you need.
--
"Dummy."
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 38
Reputation: mindfrost82 is an unknown quantity at this point 
Solved Threads: 0
mindfrost82 mindfrost82 is offline Offline
Light Poster

Re: How to make this SQL SELECT statement work in ASP.NET

 
0
  #3
Jun 11th, 2008
Thanks for the reply. What I'm actually trying to do is to get it to bind to a GridView and set strSearch equal to a QueryString @search.

So in my Page_Load, I have:
  1. Dim strSearch As String = Request.QueryString("@search")

Then I have an AccessDataSource defined in my aspx file, and this is what I currently have:
  1. <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/coindata.mdb"
  2. SelectCommand="SELECT * FROM tblCategory RIGHT JOIN tblInventory ON tblCategory.categoryID = tblInventory.categoryID WHERE (((tblInventory.type)=[strSearch])) OR (((tblInventory.country)=[strSearch])) OR (((tblInventory.date)=[strSearch])) OR (((tblInventory.eventSeries)=[strSearch])) OR (((tblInventory.grade)=[strSearch])) OR (((tblInventory.comment)=[strSearch]));">
  3. </asp:AccessDataSource>

So if I try to pass a variable onto this page using frmSearch.aspx?@search=Lincoln for example, then I get a "No value given for one or more required parameters" error.

Any help? Sorry I didn't provide more detail earlier.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 291
Reputation: ericstenson is an unknown quantity at this point 
Solved Threads: 29
Team Colleague
ericstenson's Avatar
ericstenson ericstenson is offline Offline
Posting Whiz in Training

Re: How to make this SQL SELECT statement work in ASP.NET

 
0
  #4
Jun 12th, 2008
You are doing it all wrong. How much experience in this do you have?
--
"Dummy."
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 38
Reputation: mindfrost82 is an unknown quantity at this point 
Solved Threads: 0
mindfrost82 mindfrost82 is offline Offline
Light Poster

Re: How to make this SQL SELECT statement work in ASP.NET

 
0
  #5
Jun 12th, 2008
Originally Posted by ericstenson View Post
You are doing it all wrong. How much experience in this do you have?
Not much at all lol.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 86
Reputation: dexterz is an unknown quantity at this point 
Solved Threads: 3
dexterz dexterz is offline Offline
Junior Poster in Training

Re: How to make this SQL SELECT statement work in ASP.NET

 
0
  #6
Jun 15th, 2008
Use store procedure with parametr @strSearch then pass a strSearch value through SQL parameter.value
Dexter Zaf
Ex-designz.net
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 3525 | Replies: 5
Thread Tools Search this Thread



Tag cloud for ASP.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC