.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 9th, 2004, 03:51 PM
beacon-dartmout beacon-dartmout is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 4 beacon-dartmout User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 5 sec
Reputation Power: 0
WhereClause Use in a DataGrid

I have a datagrid that needs to display records given by a Select statement with a WHERE clause that is passed in a given value by variable 'appID'. For some reason I've been unable to make it work any which way I tried.

As I'm not totally sure how to effectively pass a value in the context of a SQL Adapter to the DB, The last thing I tried was passing it to a variable and then to the SQL string. The compiler screams with the error:
quote:
BC30311: Value of type 'String' cannot be converted to 'System.Data.SqlClient.SqlCommand'.


Has anyone ever tried this?? I've looked around and most data bound to datagrids are usually simple queries, i.e., "Select * From Clients" with no filtering whatsoever.

Here's some code:




Sub BindGrid()
Dim dsAppl As DataSet
Dim conMeta As SqlConnection
Dim dadAppl As SqlDataAdapter
Dim whereClause As String = "WHERE Application_ID = '"&session("appID")&"' "

dsAppl = New DataSet()
conMeta = New SqlConnection( "Server='DOHSDBS96';trusted_connection=true;Databas e='METADATAv2'" )
dadAppl = New SqlDataAdapter( "SELECT *, Q.Type AS QType, S.Type AS SType FROM A_Table A_T INNER JOIN Quality Q ON Q.Quality_ID=A_T.Quality_ID INNER JOIN Status S ON S.Status_ID=A_T.Status_ID" & whereClause & "ORDER BY & viewstate("sortField").ToString() & " " & viewstate("sortDirection").ToString(), conMeta )
dadAppl.Fill( dsAppl,"A_Table" )
Try
AppDataGrid.DataSource = dsAppl
AppDataGrid.Databind()
Catch exc As Exception
Response.Write(exc)
AppDataGrid.CurrentPageIndex = 0
End Try
ShowStats
End Sub

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > WhereClause Use in a DataGrid


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway