943,648 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 10789
  • ASP.NET RSS
Jun 11th, 2008
0

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

Expand Post »
Can someone help me convert this SQL SELECT statement to ASP.NET code (if possible):

ASP.NET Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
mindfrost82 is offline Offline
38 posts
since Dec 2004
Jun 11th, 2008
0

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

ASP.NET Syntax (Toggle Plain Text)
  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.
Team Colleague
Reputation Points: 14
Solved Threads: 29
Posting Whiz in Training
ericstenson is offline Offline
293 posts
since Dec 2007
Jun 11th, 2008
0

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

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:
ASP.NET Syntax (Toggle Plain Text)
  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:
ASP.NET Syntax (Toggle Plain Text)
  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.
Reputation Points: 10
Solved Threads: 0
Light Poster
mindfrost82 is offline Offline
38 posts
since Dec 2004
Jun 12th, 2008
0

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

You are doing it all wrong. How much experience in this do you have?
Team Colleague
Reputation Points: 14
Solved Threads: 29
Posting Whiz in Training
ericstenson is offline Offline
293 posts
since Dec 2007
Jun 12th, 2008
0

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

You are doing it all wrong. How much experience in this do you have?
Not much at all lol.
Reputation Points: 10
Solved Threads: 0
Light Poster
mindfrost82 is offline Offline
38 posts
since Dec 2004
Jun 15th, 2008
0

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

Use store procedure with parametr @strSearch then pass a strSearch value through SQL parameter.value
Reputation Points: 10
Solved Threads: 3
Junior Poster in Training
dexterz is offline Offline
86 posts
since Feb 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: im a begginer
Next Thread in ASP.NET Forum Timeline: create shopping cart website using asp.net and c#





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC