Using User Input As Part Of A SELECT Statement
I know this is an easy one and I know I've read it somewhere, but I can't seem to write the correct format to run correctly. I am trying to build a SELECT statement base on the selected values of a dropdown list on a webform. The selected values will be part of the Table name.. ("client_info" & location_option.selecteditem.value) Can someone show me the correct syntax for adding a form variable into a SELECT statement? Thanks
View Complete Forum Thread with Replies
Related Forum Messages:
Return Variable Name As Part Of Select Statement.
hey all, I have the following query: ALTER PROCEDURE [dbo].[sp_SelectMostRecentArticle] AS BEGIN DECLARE @article_id INT SELECT @article_id = ( SELECT TOP 1 article_id FROM article ORDER BY article_id DESC ) DECLARE @comment_count INT SELECT @comment_count = ( SELECT COUNT(comment_id) FROM comment JOIN article ON article_id = comment_article_id GROUP BY article_id HAVING article_id = @article_id ) SELECT TOP 1 article_id, article_author_id, article_title, article_body, article_post_date, article_edit_date, article_status, article_author_id article_author_ip, author_display_name, category_id, category_name--, comment_count AS @comment_count FROM article JOIN author ON author_id = article_author_id JOIN category ON category_id = article_category_id GROUP BY article_id, article_title, article_body, article_post_date, article_edit_date, article_status, article_author_ip,article_author_id, author_display_name, category_id, category_name HAVING article_id = @article_id END GO as you can see, im trying to return a comment_count value, but the only way I can do this is by defining the variable. I have had to do it this way, because I cannot say COUNT(comment.comment_id) AS comment_count or it returns an error that it cant reference the comment.comment_id. But when change it to FROM article, comment; I get errors about the article_author_id and article_comment_id. And i cant add a join, because it would return the amount of rows of the comment... unless someone could help with what i Just decribed (as i would prefer to do it this way), how would i return the variable value as part of the select statement? Cheers
View Replies !
Excluding Part Of Select Statement If No Data Is Returned In Results
I have a query that returns results based on information in several tables. The problem I am having is that is there are no records in the one table it doesn't return any information at all. This table may not have any information initially for the employees so I need to show results whether or not there is anything in this one table. Here is my select statement: SELECT employee.emp_id, DATEDIFF(mm, employee.emp_begin_accrual, GETDATE()) * employee.emp_accrual_rate - (SELECT SUM(request_duration) AS daystaken FROM request) AS daysleft, employee.emp_lname + ', ' + employee.emp_fname + ' ' + employee.emp_minitial + '.' AS emp_name, department.department_name, location.location_name FROM employee INNER JOIN request AS request_1 ON employee.emp_id = request_1.emp_id INNER JOIN department ON employee.emp_department = department.department_id INNER JOIN location ON department.department_location = location.location_id GROUP BY employee.emp_id, employee.emp_begin_accrual, employee.emp_accrual_rate, employee.emp_fname, employee.emp_minitial, employee.emp_lname, department.department_name, location.location_name ORDER BY location.location_name, department.department_name, employee.emp_lname The section below is the part that may or may not contain information: SELECT (SELECT SUM(request_duration) AS daystaken FROM request) AS daysleft So I need it to return results whether this sub query has results or not. Any help would be greatly appreciated!!! TIA
View Replies !
Lookup Transform Issuing One Select Statement Per Input Row
I am using the lookup transform with the following settings: Reference table: Use results of an SQL query. The query retrieves the surrogate key and four business key columns from a dimension table which contains a few thousand rows. Columns: business keys in the incoming data are mapped to the business keys in the reference table, and the surrogate key is looked up from the reference table. Advanced: Enable memory restriction is OFF (and the other items on the Advanced tab are greyed out). I assumed that this means that the lookup transform would cache all of the rows in the SQL query, and then perform the lookups against this cache. This is the behaviour that I saw when I was running the package in my local environment in the BIDS debugger. However, a colleague was doing some profiling on our production database server, and noticed that the lookup transform is instead issuing a single SQL query for each row of input. Our production ETL server has many GBs of free RAM available (way more than enough to cache the contents of the lookup table in memory), and given that memory restriction is disabled, I don't understand why the lookup transform is behaving in this fashion. Does anyone have an explanation for this? I'm probably misunderstanding a key concept here. Thanks, Greg
View Replies !
Input Paramter As Part Of OPENDATASOURCE
I want to use an input parameter as my filename, but I get a synataxerror message. Howerve, when I hard code the filename the proc compilessuccessfully.Thanks for any help. I'm using SQL Server 2005LTR_90,LTI_ELIG_pct,LTI_REC_pct,LOW_SALARY,HIGH_SALARY FROM OPENDATASOURCE("Microsoft.Jet.OLEDB.4.0","Data Source=C:inetpubwwwrootORC_Beta_Companies"' + @infilename +'"Extended Properties=Excel 8.0")...[summary_data$]Syntax message:Msg 102, Level 15, State 1, ProcedureimportExcelSpreadSheetIntoeNavigator_DataORC, Line 244Incorrect syntax near 'Microsoft.Jet.OLEDB.4.0'.
View Replies !
Select Statement For User Pyramid
I have a user table for an organization that can best be described as a pyaramid. We are using the terms parent and child to define the relationship between users. Each user is a child under a specific parent; accept for the top person who is not a child under anyone. Each user can be a parent over many children. User A has a parent - User B User B has a parent - User C User C has a parent - User D User D has not parent I want to do is create a select statement that would return all the parents for a particular user. For instance, if I ran the select statement for User A, it would return: User A User B User C User D If I ran it for User C, it would return: User C User D Ideas anyone on how I can accomplish this.
View Replies !
First Time SELECT CASE Statement User
Hi, I have created a login page (webform1) that enables me to enter my user number and password and if correct it re-directs to webform 2 where all data related to the usernumber that was entered in the login page, appears. Now I want to be able to set different re-direct pages dependant upon different users as some may require more privileges then others. As for my query I have 2 types of users: staff and managers. I want to set the login page so that if staff logins in it goes webform 3 and if manager logins in it goes webform 4. My table in the Sql database is called Users & the fields are: unumber(pk), pwd, userRole, forename, surname. I have been advised to use CASE statements, yet I do not know how to use them. Below have left my code of a simple login without the userRole validation. Please help! Sub cmdLogin_ServerClick If ValidateUser(txtUserNumber.Value, txtUserPass.Value) Then Dim tkt As FormsAuthenticationTicket Dim cookiestr As String Dim ck As HttpCookie tkt = New FormsAuthenticationTicket(1, txtUserNumber.Value, DateTime.Now(), _ DateTime.Now.AddMinutes(30), chkPersistCookie.Checked, "your custom data") cookiestr = FormsAuthentication.Encrypt(tkt) ck = New HttpCookie(FormsAuthentication.FormsCookieName(), cookiestr) If (chkPersistCookie.Checked) Then ck.Expires = tkt.Expiration ck.Path = FormsAuthentication.FormsCookiePath() Response.Cookies.Add(ck) Dim strRedirect As String strRedirect = Request("ReturnURL") If strRedirect <> "" Then Response.Redirect(strRedirect, True) Else strRedirect = "webform1.aspx" Response.Redirect(strRedirect, True) End If Else Response.Redirect("webform3.aspx", True) End If End Sub
View Replies !
Select Statement Within Select Statement Makes My Query Slow....
Hello... im having a problem with my query optimization.... I have a query that looks like this: SELECT * FROM table1 WHERE location_id IN (SELECT location_id from location_table WHERE account_id = 998) it produces my desired data but it takes 3 minutes to run the query... is there any way to make this faster?... thank you so much...
View Replies !
Excel XP Removes AS Part Of Statement
I am trying to help an individual with a MS Query. In Excel 97 MS Query the script was written: TO_CHAR(LABTRANS.STARTDATE, 'YYYY') AS YEAR In Excel XP I can run an existing Query and it returns the data as expected, but when I view the query it is: TO_CHAR(LABTRANS.STARTDATE, 'YYYY') AS 'YEAR' However if I try to create a new query using XP MS Query then the AS YEAR or AS 'YEAR' will be removed by MS Query and my column header will now be: TO_CHAR(LABTRANS.STARTDATE, 'YYYY') Here are my examples: MS Excel 97 Query SELECT LABTRANS.LABORCODE, LABTRANS.REGULARHRS, LABTRANS.OTHRS, LABTRANS.OTSCALE, LABTRANS.STARTDATE, LABTRANS.TRANSTYPE, VALUELIST.VALDESC, TO_CHAR(LABTRANS.STARTDATE, 'YYYY') AS 'YEAR' FROM MAXIMO.LABTRANS LABTRANS, MAXIMO.VALUELIST VALUELIST WHERE LABTRANS.TRANSTYPE = VALUELIST.VALUE AND (LABTRANS.TRANSTYPE IN (SELECT VALUE FROM VALUELIST WHERE LISTNAME = 'LTTYPE' AND MAXVALUE = 'NON-WORK')) AND LABTRANS.LABORCODE IN (SELECT LABORCODE FROM LABOR WHERE LABOR.TYPE = 'CUPE' AND LABOR.CREWID IS NOT NULL AND LABOR.LA9 = 'N' AND LABOR.LA16 = 'WW' OR LABORCODE = '210308') AND VALUELIST.MAXVALUE = 'NON-WORK' ORDER BY LABTRANS.STARTDATE MS Excel XP Query SELECT LABTRANS.LABORCODE, LABTRANS.REGULARHRS, LABTRANS.OTHRS, LABTRANS.OTSCALE, LABTRANS.STARTDATE, LABTRANS.TRANSTYPE, VALUELIST.VALDESC, TO_CHAR(LABTRANS.STARTDATE, 'YYYY') FROM MAXIMO.LABTRANS LABTRANS, MAXIMO.VALUELIST VALUELIST WHERE LABTRANS.TRANSTYPE = VALUELIST.VALUE AND (LABTRANS.TRANSTYPE IN (SELECT VALUE FROM VALUELIST WHERE LISTNAME = 'LTTYPE' AND MAXVALUE = 'NON-WORK')) AND LABTRANS.LABORCODE IN (SELECT LABORCODE FROM LABOR WHERE LABOR.TYPE = 'CUPE' AND LABOR.CREWID IS NOT NULL AND LABOR.LA9 = 'N' AND LABOR.LA16 = 'WW' OR LABORCODE = '210308') AND VALUELIST.MAXVALUE = 'NON-WORK' ORDER BY LABTRANS.STARTDATE In Excel XP, no matter what I put in the AS part of the statement when I execute the script it runs and removes the AS part from the statement. This only happens when I run the script from MS Query, if I stay in Excel and just refresh the data, then it works fine. I did not have this problem in Excel 97. Any suggestions?
View Replies !
SQL Statement - Part Dates Selection
Hi all, I have a database with a field which contains a load of dates in this format 01/03/1998 What I want to do is select all the records from the database where the month of the date is what ever, this month or the month the customer selected etc. I suspected it may be something like the following (which doesnt work) sql = "SELECT * FROM avail_lowermill WHERE CH_Arrival.month = " & showmonth & " ORDER by CH_Arrival" Can anyone suggest how I can do this? Thanks in advance
View Replies !
User Input
Hi all, Can anyone tell me about how to prompt a user to type when running a sql statement through query analyzer. thanks Jay
View Replies !
User Input
Hi all, Can anyone tell me about how to prompt a user to type when running a sql statement through query analyzer. thanks Jay
View Replies !
User Input
Is it possible to allow user input via a Reporting Services Report? What I mean is could a report be created that would allow someone using the report to enter a number that would be written to the SQL database?
View Replies !
User Input
I have created a query that has a "When" and an "And" function. I know need to make the query run on user input, i want it to ask for the date, then name to run the query
View Replies !
User Input With Sql...
Afternoon... I have a database for a pretend dvd hire company and need to create a query that uses user input as part of the query. Ie, select * from dvd where actor = 'Tom Cruise'; The 'Tom Cruise' part of the query needs to be user input every time the query is ran... Can you help? Many thanks in advance!?
View Replies !
User Input - SQL Paramaters
Hi, Just wondering if I could make sure that "hackers" don't tamper with my querystring - which is a parameter for a SQL query. i.e... Dim ListOfValues as string = request.querystring("listOfValues") 'Output would be this: 324234,5445,554654,45632,SQL command : Delete From table where product_id IN (@ListOfValues) cmd.paramaters.addwithvalue("@ListOfValues", ListOfValues ) How can I validate it so that hackers can't add any characters other than 'numbers' and ' , ' to the sql parameter? I have tried to tryparse the 'ListOfValues ' as an integer - by replacing "," with "" but an integer overflow occured. Any questions or ideas? Thanks
View Replies !
User Input Conversion
To: All, well here's a problem that I encountered, i got a textbox that is used to store the Date of Birth of a user. So when user keys in something, it is store as a string. However i wish to convert it into a datetime so that i can store it into my database. Anybody know of a way to help? i've tried countless methods but doesn't seem to work. Please give me a hand guys.... Thanks From: iaciz
View Replies !
User Input In SQL Query
Hi, I am new to ASP.NET so pordon me if my questions seems to be stupid. I was given an assign to develop a ASP that would return results from a SQL server. The problem is that part of my query to the SQL server comes from the webform select a.invnum, a.invdate, a.duedate, a.invamt,a.payamt from vpshead a inner join vendors b on (a.vendnum = b.vendnum) where (a.vendnum = " & user.text & " ) and (b.vendpass = " & Pass.text & " ) and (a.payflag <> 'V') and ( (a.invamt <> 0) or (a.payamt <> 0) )and (a.chkno = '') order by a.invdate" As your can tell I am using the user.text and Pass.text in my query which will come from the web form. I know this is wrong but how else can I do it? Thanks
View Replies !
User Input In SQL2000
Hello. I'm using SQL query analyzer to run some queries against anSQL2000 DB. Unfortunately, my previous SQL experience is some OralceSQL I took in school.To put it simply, I'm trying to write a query to pull records thatmatch a variable input. In Oracle, I'd use a substitution variablelike this...SELECT * FROM jobs WHERE jobid = &job_id_to_query;Is this possible under SQL2000? Is this only a feature of SQL*Plus?TIARich
View Replies !
Getting User Input From Queries
How do I get user input in MSSQLServer 7.0 so that it asks me to input some value and then searches accordingly THis method is avaiable in Oracle Server using the & operator Thankx in advance
View Replies !
How To Get User Input In Query
I m new to SQL Server. Before this I was using access. In access one can have user inputs easily .. for example where receivedate=[enter date] how I can get userinputs in SQL server Query.... Forgive me if it is a dumb question
View Replies !
Need To Get Input In Parameter From End User
Hi, I am trying to make a simple stored procedure which I want to take input on every run from end user: SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO declare @sku varchar(20) insert into skua (sku,SumOfQtyNum) (select sku,sumofqtynum from sku where @sku = sku.sku) it is working but not asking parameter values (I want to use passthrough query after that in Access) thanks AA
View Replies !
User Input Data In T-sql
Hi there I want to give dynamic input to the t-sql code in sql analyzer.how do i do that.... Like adding 2 numbers declare @a integer,@b integer,@c integer --I dont want to give like this --set @a = 5 --set @b = 10 set @c = @a + @b can anyone help me with this regards Vic Vicky
View Replies !
PASS User Group Austria Looking For MS-SQL Professionals To Take Part
Dear group,PASS (SQL-Server user group) is about to start founding a branch inVienna. I went to SQLCON and met some guys from the German PASS groupand decided to become a member of PASS, decided to look for otherindividuals to take part in an Austrian branch of PASS based in Vienna,so whoever is interested may take a look athttp://www.sqlpass.de/Default.aspx?tabid=191 in order to get to contactme to get things going.================================================== ================Following is germanPASS Usergroup Austria wird sich bald gründen.Liebe österreichische Mitglieder der SQL-Server Usergroup PASS, aufder gerade zu Ende gegangenen SQLCON habe ich verschiedene engagiertedeutsche Mitstreiter der deutschen PASS getroffen und mich spontanentschlossen, den ersten Kick für eine österreichische Usergroup mitSchwerpunkt im Raum Wien zu legen. Informationsaustausch, technischeHilfestellung, Networking, Kennenlernen und regelmäßige Treffen, alldas kann für einen Datenbank-Administrator / SQL-Server-Entwicklereine Erleichterung und Aufwertung der Arbeit sein, da viele DBA's inihren jeweiligen Unternehmen Einzelkämpfer sind.Über die Kontaktaufnahme von Interessenten würde ich mich sehrfreuen unter http://www.sqlpass.de/Default.aspx?tabid=191Kurz zu meiner Person: nach Informatikstudium in Deutschland kann ichauf mehr als 10 Jahre Berufserfahrung zurückblicken davon 8 Jahre mitverschiedenen RDBMS (SQL-Server, Oracle, DB2, MySQL). MeinArbeitsschwerpunkt heute ist die Administration und Programmierung vomSQL-Server (Reporting, Replikation, Cluster) (22.09.2005)================================================== =============Kind regards Uli
View Replies !
Search Based On User Input
I have a search page that allows users to type/select values contined within the entry they're looking for. My SELECT statement returns columns in a table that get compared to the user input. So if someone selected Status (Open) then all of the 'Open' Request entries should populate the search page. How do I phrase the SELECT statement to compare values if the user gives them, but ignore the fields where no data was input when it's searching? So a search where no values were entered would return every Request Entry instead of an error; no entry. Thanks!
View Replies !
Pull Between 2 Dates From User Input
I want to pull dates from my database that are between to set dates i have written a query that does this which looks like this: "SELECT OCH_ID, empno, Selected_OCD, Start_Time, End_Time, Selected_OCDay, Selected_DOM, Selected_Month, Selected_Year FROM dbo.ICT_On_Call_Hours WHERE (CONVERT (datetime, LEFT (Selected_OCD, 2) + '/' + SUBSTRING(Selected_OCD, 4, 2) + '/' + RIGHT (Selected_OCD, 4)) >= CONVERT (datetime, LEFT ('12/02/2007', 2) + '/' + SUBSTRING('12/02/2007', 4, 2) + '/' + RIGHT ('12/02/2007', 4))) AND (CONVERT (datetime, LEFT (Selected_OCD, 2) + '/' + SUBSTRING(Selected_OCD, 4, 2) + '/' + RIGHT (Selected_OCD, 4)) < CONVERT (datetime, LEFT ('14/02/2007', 2) + '/' + SUBSTRING('14/02/2007', 4, 2) + '/' + RIGHT ('14/02/2007', 4)))" This works when the dates are included in the statement but when i try and use parameters to pull them in like this: "SELECT OCH_ID, empno, Selected_OCD, Start_Time, End_Time, Selected_OCDay, Selected_DOM, Selected_Month, Selected_Year FROM dbo.ICT_On_Call_Hours WHERE (CONVERT (datetime, LEFT (Selected_OCD, 2) + '/' + SUBSTRING(Selected_OCD, 4, 2) + '/' + RIGHT (Selected_OCD, 4)) >= CONVERT (datetime, LEFT ('@Choice1', 2) + '/' + SUBSTRING('@Choice1', 4, 2) + '/' + RIGHT ('@Choice1', 4))) AND (CONVERT (datetime, LEFT (Selected_OCD, 2) + '/' + SUBSTRING(Selected_OCD, 4, 2) + '/' + RIGHT (Selected_OCD, 4)) < CONVERT (datetime, LEFT ('@Choice2', 2) + '/' + SUBSTRING('@Choice2', 4, 2) + '/' + RIGHT ('@Choice2', 4)))" I then recieve the following error message why is this? ERROR -------------------> Syntax error converting datetime from character string. Any Help would be greatly appreciated thanks
View Replies !
User Input In Query Analyzer
Hi folks, i am lookin for an option in the QA to take user input while executing a query. just like we do in SQLPLUS: SELECT * FROM dept WHERE deptno=$abc here it would ask me for the deptno. I guess it's a very handy feature and we could test our variables and calculations withing the procedures etc. Is there a way, or any substitute? Howdy!
View Replies !
Need To Pass User Input Through To SQL Query
Hello Everybody, I am sure this has been asked a thousand times before in a thousand different ways, but here goes... I am in need of the ability to prompt users for a From Date and To Date to insert into a WHERE clause in SQL queries. What is the easiest least painful way of accomplishing this? A great many of our customers utilized SQL Server Express or MSDE, so they do not have the full gambit of SQL tools handy. Believe me when I say that I have searched high and low across the internet for this solution. I was hoping I might be able to accomplish this through VB Script or J Script. Or, anything reasonable. Thanks in advance for your time and patience, Rocky Mountain Tech
View Replies !
How To Save User'input In Datagrid In C#
hi in my windows application.there is a data grid ,2 textboxes and 2 buttons.. if i m giving a sql query lik "insert into information values('ab',67)"; it is taking manual data from user,and saving that to datagrid.bt if i try to put sum data from user via textbox aft pressing save button its giving an additional msg at run time i.e .Additional information: Object reference not set to an instance of an object. plz help me hw to resolve.dis
View Replies !
User Input During Report Generation.
Hello, I'm trying to do something simple that has turned out to be a frustrating problem. I have a field in my report that needs to be populated by user input. Based on this user input, I will use the field in a calculation. The simple solution to me, was to create a custom assembly that has a function that uses Console.Write("Input Data") and Console.readline() to assign the input to a string, and then return that string to the report. This works fine in a test console application, but when I copy and paste the code to my custom assembly, it returns #Error to the report. I've debugged, and found that when I hit F10 on Console.Write("test"); it skips right over it, and nothing happens. It also skips over Console.readline(); with nothing happening. This makes me unable to take the user input and set the textbox equal to that value. Am I doing this completely wrong? Is there something I'm missing, or just not understanding correcly? It seems like reporting services has to have this option. I'd really appreciate some advice. Thanks! -Paul
View Replies !
How To Update Values From The User Input?
Hi I have a table(tblA) as follows Col1--------------col2---------col3-----col4 London------------1131---------299------Barking Didicot-----------3451---------429------Dansdon Barking/ASton-----1131---------345------Singleton Vander/ADon/cam---3907---------299------derby Null or Blank ---1131---------423------Addington Expecting the Data should display look like below London------------1131---------299------Barking Didicot-----------3451---------429------Dansdon Barking/ASton-----1131---------345------Singleton Vander/ADon/cam---3907---------299------derby But when user change the col2 value (1131) to 113999, this should be changed to all values where col2 is 1131. Please Help
View Replies !
Running Query From User Input
I would like to setup a query where the user is firstly prompted to input the information e.g. if they are trying to locate a particular person from a telephone database they would be prompted to enter the surname for that person.
View Replies !
SubQuery In Both SELECT And WHERE Part. How To Optimise?
Ok I have the following SQL, I have a subquery in the SELECT part but also the same subquery in the WHERE part as well.What I'm trying to do is get all parents that have children OR get all parents with no children OR just get all parents regardless (@HasResponses is a BIT that can be 1, 0 or null). At the same time I want to count the total number of children in the select list, but I'm having to copy the same subquery in the SELECT and WHERE parts which doesn't seem terribly optimal to me (maybe it is, that's why I'm asking). I've tried referencing the column alias in the select list (AS [Responses]) for the where part (@HasResponses = 0 AND [Responses] = 0), but it doesn't seem to work.Is this the most optimal way to do it? Is there a better way? I'm working with SQL Server 2005.SELECTf.FeedbackText AS [Feedback Comment],u.Name AS [Feedback Author],f.CreatedDate AS [Created On],(SELECT COUNT(*)FROM FeedbackResponse frWHERE fr.FeedbackID = f.ID) AS [Responses]FROM Feedback fINNER JOIN [User] u ON f.StaffID = u.StaffIDWHERE f.CreatedDate >= @DateFromAND f.CreatedDate <= @DateToAND(@HasResponses IS NULLOR(@HasResponses = 1 AND(SELECT COUNT(*)FROM FeedbackResponse frWHERE fr.FeedbackID = f.ID) > 0)OR(@HasResponses = 0 AND(SELECT COUNT(*)FROM FeedbackResponse frWHERE fr.FeedbackID = f.ID) = 0))
View Replies !
Dynamic WHERE Operator Based On User Input
Let's say I have a table with 3 fields: an ID field (primary key, set as an id field, etc.), a Name field (nvarchar50), and an Age field (int). I have a form that has three elements: DropDownList1: This drop down list contains 3 choices- "=", ">", and "<". Age: This text box is where someone would enter a number. Button1: This is the form's submit button. I want someone to be able to search the database for entries where the Age is either equal to ("="), greater than (">"), or less than ("<") whatever number they enter into TextBox1. The code-behind is shown below. The part I'm confused about is that if I load this page, the query works the -first- time. Then, if I try to change the parameters in the form and submit it, I get the following error: "The variable name '@Age' has already been declared. Variable names must be unique within a query batch or stored procedure." Any help would be appreciated. Here is what I'm using in my code behind: protected void Button1_Click(object sender, EventArgs e) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("SELECT * FROM People WHERE Age "); switch (DropDownList1.SelectedValue) { case "=": sb.Append("= "); break; case ">": sb.Append("> "); break; case "<": sb.Append("< "); break; } sb.Append("@Age"); SqlDataSource1.SelectCommand = sb.ToString(); SqlDataSource1.SelectParameters.Add("Age", TypeCode.Int32, Age.Text); }
View Replies !
Query Database User Input From ListBox
I have a problem selecting fields from a table where fields are equal to user input from a listbox. example listbox of zip codes: 33023[red]22300[/red]39844[red]29339[/red]23883[red]38228[/red] user wants to retreive highlight zip codes from database.connection working perfect.Thank you for your help.
View Replies !
How Can I Enter A User Input Into 2 Tables Simultanously?
I'm running asp.net on an XP machine with MSDE 2000 as the database. I want to create a user table with a userid and password. I have a second table that contains details about the user such as home address and phone number etc. When the user first signs up, I want their userid to go into the user table and the user detail table. In my SQL insert command, I can't get @userId to go into both tables. So my question is how do I get the userID to go into both tables or is there a better way of doing this altogether? Thanks, Tom
View Replies !
Displaying Multivalue User Input In Textbox!?
Is it possible to display multivalue user input parameters within the report, so the user can see what he just entered in the parameters? I only can get the first or the second value within a textbox: (parameters!year.value(0) / parameters!year.value(1)) The desired output i want to achive is that the multiple selections are displayed within one text box: Example: Parameter Year: 2006,2007,2008 Any suggestions?
View Replies !
Error Message For Wrong User Input
how can i make a customized error message for a wrong input of parameters? let's say i have a parameter which requires user input of companyID and it should compose of all numbers only. if not followed an error message will be prompted to the user... "please enter numbers only..." or something like that... please... just wondering if its possible...
View Replies !
How To Update User Input Data Into Sql Server
hi , i am new to this. how should i update the user input values into sql server database? i am using asp.net and c# FIELDS are- userId, name, description, startTime, endTime, audiencePassword, presenterPassword i know it must be simple...but i haven't worked on this before. Jaimin
View Replies !
Update Statement To Include Multiple Parameterised Input
I want to do an update query like the following:UPDATE tblUserDetails SET DeploymentNameID = 102 WHERE (EmployeeNumber = @selectedusersparam)Is there some simple way to add the @selectedusersparam as value1,value2,value3 etc. or do I have to input it with this type of syntax:UPDATE dbo_tblUserDetails SET dbo_tblUserDetails.DeploymentNameID = 102WHERE (((dbo_tblUserDetails.EmployeeNumber)=value1 Or (dbo_tblUserDetails.EmployeeNumber)=value2));Help appreciated.Many thanks.
View Replies !
Apostrophes In Input String Terminating Update Statement
Hi. I have an update statement that accepts a user's text input. problem is that the string terminates the sql update statement if there is an apostrophe in it. so, headline='i like my brother's car" willl terminate after "brother". "s car" is read as sql. how is this resolved? Code: Dim MyCmd2 As New Data.SqlClient.SqlCommand("SET ANSI_WARNINGS OFF " & _ "UPDATE EditProfile " & _ "SET headline='"+ Me.tb_headline.Value+"', about_me='"+ Me.ta_aboutme.Value+"', edit_date='"+System.DateTime.Now.ToString+"' WHERE email_address='"+Context.User.Identity.Name.ToString+"' " & _ "SET ANSI_WARNINGS ON ", MyConn)
View Replies !
Update Records From User Input - Any Good Samples?
Edited by SomeNewKid. Please post code between <code> and </code> tags. Right now i'm just trying to get the page to update SQL, but its not working no errors or anything but still not updating?!?! Any ideas? Thanks in advance Ben <% Dim cnnSimple ' ADO connection Dim rstSimple ' ADO recordset Set cnnSimple = Server.CreateObject("ADODB.Connection") cnnSimple.Open Blah Blah Blah Set rstSimple = cnnSimple.Execute("SELECT * FROM WK_DATA WHERE WEEK_NUM = 2") %> <input name="Submit" type="button" value="Add"> <% If Request.Form("Submit") = "Add" Then cnnSimple.Execute("UPDATE WK_DATA SET PRICE = (PRICE + 1) WHERE WEEK_NUM = 2") rstSimple.update End If cnnSimple.Close Set cnnSimple = Nothing %>
View Replies !
Prompt For User Input In Criteria Field Of View
In Access, I use [Enter Date] in the Criteria field of the Query. I tried the same thing in SQL Server in the Criteria field of the View and it does not recognize this. Is there a comparable command in SQL to get user input into the Criteria field of a view?
View Replies !
Comparing And Rounding User Input Variables To Table Values?
HiThe scenario:The price of products are determined by size.I have a Prices table that contains 3 columnsWidth Length and Price.User inputs their own width and length values as inWidth and inLength.It is unlikely that these values will exactly match existing lengths and widths in the price table.I need to take these User Input values and round them up to the nearest values found in the Prices table to pull the correct price.What is the most efficient way of achieving this?Thanks for your time.C# novice!
View Replies !
|