User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 391,993 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,257 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 669 | Replies: 5
Reply
Join Date: Dec 2004
Posts: 37
Reputation: mindfrost82 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
mindfrost82 mindfrost82 is offline Offline
Light Poster

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

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

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]));

I'm trying to use it as a SelectCommand.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2007
Posts: 287
Reputation: ericstenson is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 28
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

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

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

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

  #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:
Dim strSearch As String = Request.QueryString("@search")

Then I have an AccessDataSource defined in my aspx file, and this is what I currently have:
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/coindata.mdb"
        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]));">
    </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  
Join Date: Dec 2007
Posts: 287
Reputation: ericstenson is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 28
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

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

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

  #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  
Join Date: Feb 2005
Location: Los Angeles, CA
Posts: 86
Reputation: dexterz is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 2
dexterz dexterz is offline Offline
Junior Poster in Training

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

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb ASP.NET Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 9:51 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC