ADO.NET :: SQL Searches Based On User Selectable Fields?
Oct 14, 2010
This is the second time I've searched on this and came up not fully understanding why this isn't possible. Say you have one text box, but you want to be able for a user to search by "company name," "job number," or "Order No," So you put one text box and a drop down list where the user can select what field to search.
Here is what I would like to do Select [order_no], [job_no], [company_name] From [order_tbl] WHERE @var1 Like '*@var2*' (maybe not totally correct syntax, but you get the picture....and @var1 is set from the selection of the dropdownlist and @var2 is set from the text box).
What I do now is three separate SQL statements. If DropDownlist1.SelectedValue = 1 then do, if it = 2 then do, etc.
But when you have a large select statement with table joins, you have to make any changes three times, and it seems easy to make a mistake...not to mention if you have more than three choices, you have an SQL statement for each choice.
Am I misunderstanding that it isn't possible to do a variable field name so I can have one select statement to work with? And if it isn't possible, I just wish I could wrap my head around why, because it seems such a simple thing to do.
In my application, there is only a login page and a report page. When the user enters his login credentials he will be redirected from the login page to the reports page. I am using forms authentication for this purpose.
On the reports page I will be displaying various reports (using Telerik reporting) based on user inputs for various fields.
Now here is the funnier part; My application works correctly in all browsers (including Safari on windows platform). But when I open it in an Ipad I am getting the below error,
"Potentially dangerous request.form value was detected from the client " This error occurs when the forms authentication redirection happens from the login page to the reports page.
I tried a variety of solutions like setting ValidateRequest="false" & requestValidationMode="2.0" , but none of them helped. I also tried removing the forms authentication and that also didn't
We're developing a web app with a home page that opens giving the user capability to do different searches. The search results are displayed in a grid. Each row has an open link. The user clicks it and another web page opens with all sorts of detailed info on the selected item. The boss would like to have the new web pages open cascaded the way you can in a windows app - each new window is on top and slightly offset from the last one.Can this be done with a web app? Is there a javascript solution or something in the framework that cann accommodate this?
I'm trying to set profiles/themes using a basepage to allow the colour of my site to change for users. I can do this on a single page but I'm trying to do this site wide and am getting an error.
I've been watching http://www.asp.net/general/videos/how-do-i-create-user-selectable-themes-for-a-web-site this tutorial
but I'm getting errors at the final step...
System.NullReferenceException was unhandled by user code Message="Object reference not set to an instance of an object." Source="App_Code.gflsvdcc" StackTrace: at BasePage.OnPreInit(EventArgs e) in D:WebsitesBalticQuarter19.01.11App_CodeBasePage.vb:line 9 at System.Web.UI.Page.PerformPreInit() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) InnerException:
is the error, The error occurs because of the line 9 =
What is the best way to do the above? Basically i have a drop down list box with a list of names pulled from a database. When someone selects a name i would then like to populate two further boxes with the persons Login ID and Email address which are held on the same DB. I have currently been using Combox1_selected index change and then running a select query on the database to fill in the other fields - unfortuntly this is too slow. There must be a better way then this? I will also need to put the values in a DB in a later stage so will need to be able to retrieve these values.
As an infopath developer this can be done easily on InfoPath using a filter - is there anything similar in ASP.net
ive a DB in access with a single table and no primary key, actually i dont need a primary key but i can consider a date field plus another to make an index. however i want to add a counter field based on every change of date field, for instance ill have many records of 20/May and all must have the same id then when the date is different, the next group of records with that new date must show 2 etc.. is it a quick way to update my database?
I currently have this working somewhat as follows aspRadioButtonList ID="leavingCert" CssClass="radio pc2 top8" RepeatDirection="Horizontal" runat="server" AutoPostBack="True" OnSelectedIndexChanged="includeDaft_CheckedChanged">"But the problem is this refreshes the page is it this possible without refreshing the page
I am trying to write a script in Visual Studio 2008 (using a VB project) that will, upon the clicking of a button:
- An file object will be created.
-Said file object will read in a number of files from a specified file path.
-A dataset will be created and populated with fields from two columns within a database table; app_id and company_name.
-The script will read through the file names and fields recorded in the dataset, renaming the file to the app_id if the original file name contained the company_name.
The code I have so far to do this:
[Code]....
The problem is that currently this code will only rename the file if the file name and company_name match exactly, ideally I'd need to include a clause to make it rename if the file name is "LIKE" or "contains" the company_name. To be honest I'm not even sure if what I want is possible, or if what I have is even on the right track. So far my own research into the issue has been less than conclusive.
I am using ContainsTable() to perform a full text search on a field (of type varbinary()) and am I wondering if there is a good way to return an excerpt of text around at least one location where the keyword matched the text in the field.Example:User searches for "computer science".The following sentence exists in the varbinary() field: "This book is about computer science and other IT related fields."I would like to return an excerpt around the words "computer science", something like: "...book is aboutcomputer science and other IT..."
I'm have on my web page a text search box which I want users to type in there favourite football team and this will display a gridview of the teams with the replica shirts I offer.
This is where I thought about creating a stored procedure to carry out this task.
I looked online for ideas but I not found anything as yet.
I created a simple search form which populates a gridview from sql server. I use 'contains' on a varchar(max) field which has a full text index. I find if I do a search for "Mexico Argentina", I get multiple results, which is good.One thing my sql server stored procedure is doing is inserting the word 'AND' between words. I do this because I want all words to be found. So if the user inputs "Mexico Argentina", I am converting that to "Mexico AND Argentina"But if I have even one 'noise word' in the search string, I get no results at all. For instance, there might be a sentence in my database table saying "I prefer Mexico to Argentina" but if I put that sentence in, I get no results at all. The database is seeing my converted string:I AND prefer AND Mexico AND to AND ArgentinaAnd finds nothing.I also have another form, which does a more advanced search that allows 'exact phrase'. If the user chooses 'exact phrase', then I don't insert AND anywhere. Instead, I surround his phrase with 4 apostrophes - 2 before the phrase, and 2 after.So now the database sees:' ' I prefer Mexico to Argentina ' ' (I've put a space between apostrophes here to make it clearer to view.Now I not only get no results, I get an error message.
I'm trying to allow logged user who are in department XYZ to perform some task for my third party App. I have two SQL tables named Users & UserList. The third party app (GoldMine) graps the USERNAME from the Users table and store it as UserID which I then referecnce SessionID. The UserList table has two columns (GM_UserName & Department) which I'm interested in. When a user login into the 3rd party app (GoldMine), i then compare the USERNAME (from Users table) to GM_UserName (from UserList table) and see whether GM_UserName is in = 'Dept XYZ'. Take a look at the SQL query below.
sqlDept = "SELECT USERNAME FROM Users LEFT JOIN UserList ON UserList.GM_UserName=Users.UserName WHERE UserList.Department ='Dept XYZ'"
I'm able to do this.
If Session("Userid") = "TestUser1" Or Session("UserID") = "TestUser2" Then Do this Else Do that End If BUT unable to do this... If user's Department = 'Department XYZ' Then Do This Else Do that End IF
I want to display a menu (which will be strongly typed with it's own unique model) across all pages only if a user is logged in.What menu items are available depend on the user's role and also I'll need to hit the repository to get numbers like "x Messages", etc
Been scratching my head for a simple solution here. Don't want to create something that need changes all over the place.All my controllers derive from a BaseController, all my Models from BaseViewModel....probably where I'll be implementing functionality for this.
I have table called ROLE with fields (id,name,permission) example values (1001,madhu,hr)
I have another table called LOGIN with fields(id,DOB,password) example values(1001,24101989,madhukumar)
What i want is , if i login using the LOGIN table ,it check the id and permission in the ROLE table , if the permission is 'hr' it enable to access the menu , or if the permission is any other it just print the error message ("no permission")
Note: menu is placed in master page , but login is not in the master page ...
I have LOGIN PANEL for student, and I want to disable it in different page. And only the admin can enable and disable it. I dont know the logic behind here.
I'm using ASP.NET MVC 3.I would like to create an action filter to determine if a user can access a view. I have a User class with properties like IsAdministrator, IsTrusteeUser and IsAuditUser. How would I create an action filter to block certain users if the don't belong in some of these roles?And aslo how would I use this in my views to hide/display certain controls?
In an ASP.NET page I have added two user control with a dropdownlist each one. The selection of a dropdownlist should be changed the query to the second user control.What is the most efficient way to pass the selected value of dropdownlist to the second?I initially thought of creating a public event (public string OnClientSelectedIndexChanged) while the first user control and outsource through a public string SelectedValue the selected value of the second user control:
I am trying to reconstruct a date/time period from five data elements Year, StartMonth, StartDate, EndMonth, EndDate If the event starts on June 5 and ends on June 6, 2010 - The label would read June 5 thru 6, 2010. If the event starts on June 30 and ends on July 2, 2010 - the Label would read June 30 thru July 2, 2010. and if the event starts on June 5 and ends on June 5, 2010 - The label would read June 5, 2010. I've tried a few variations without success. This one comes closest to what I'm aiming for.
And we have seen all these in a user registration form. But what if I want to add more fields to it. For example, take a look at this website, this registration page has a lot more fields for users to enter information: [URL] This regirtaion page has the information for Street Address, Suburb, Gender, DOB and lot more. How do I add these fields into my registration page. I have heard of something called profile. But how do I intergrate profile into this, if this is what we use to add more fields to user registraiton page. share a sample working code of user registrtion page with more fields.
Can u make the tabpanel headers not selectable, so the users cant skip tabs. I have buttons on each panel that shows the next panel but the users can skip panels by clicking the panel headers. I want the panel headers to be visible so the users can see which section they are on but stop them selecting panels from the headers.