Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change the Select command in the Data Source

Status
Not open for further replies.

MzKitty

Programmer
Oct 28, 2003
254
US
Hi. I'm using Vs2008 and I need to be able to change the Select command in my DataSource according to what the user enters. If the user doesn't enter a customer ID then I want to be able to change the select to all customer ID's. I don't know how to fill the gridview with the customized select, so this is the next best thing. I have tried the following code, but it doesn't work.

strSql = "Select * from Tkhist1 where LocationID = '" & inTxtLocID.Text & _
"' and (TicketDate >= '" & strFromDate & "' and TicketDate <= '" & strToDate & "');"
SqlDataSource1.SelectCommand = strsql

I am at a stand still and would appreciate any help you can give me and don't tell me to google it - I have.

Thanks
Cathy
 
don't use datasource controls. they cause more problems then they solve. just access the data in code this gives you full control over the behavior.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
I ended up adding a 2nd gridview and datasource to the application. I based it on if the CustomerID <> "" then I made gridview1 visible and vise versa for gridview2. I couldn't get the code down good enough to use my sql statements to fill the gridview by custom code. There just aren't many examples of that anywhere. Thanks for your reply.
Cathy
 
I couldn't get the code down good enough to use my sql statements to fill the gridview by custom code. There just aren't many examples of that anywhere.
how? there is code all over the internet. ado.net is the basis of all .net database access. MSDN, Tek-Tips, have a plethora of information on the topic. and then there is
Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top