Expand my Community achievements bar.

use a value from from for a select statement

Avatar

Former Community Member
Hello All!



It seems like a pretty simple question, but I can't find the answer, or I'm not looking in the right area.



I have a form, it has a employee number the user fills in. I have a connection created to SQL 2005. I want to call that employee number which is EmpNumTxt so it part of my Select statement. So when a employyes number is put in, it displays the name of that person.



SELECT EmpName from EmpTable WHERE "the text box on my form" = EmpNumber.



How do I call that value in the text box?



Thanks!



Jim
6 Replies

Avatar

Former Community Member
Hi Jim,



If I understand you are asking for the proper naming syntax for the textfield you added to your form.



1) In the Script Editor position your cursor where you want the textfield object proper name.



2) Move the mouse pointer over the textfield on your form and hold down the ctrl key. The mouse pointer will turn to a "V" shape. Click the textfield object and it will paste the proper naming syntax where the cursor is positioned in the Script Editor.



If I misunderstood what you were conveying please explain further.



Thanks

Pam

Avatar

Former Community Member
Hi Pam!

Thanks for the reply. I tried that, but it didn't work. Let me try to explain this better.



I have a form with a employee number on it. I have a table in SQL that holds employess name, number address, etc. So I need when a user enters employee number '55', the name Tom Jones will appear in another text box.



The way I would normally do this is..

SELECT [Name]

FROM List2

WHERE [File] = @Numb



@Numb would equal that value in the employee number text box. How can I take that value in my employee number box and pass it to my SELECT statement. Thus retruning a emp name.



Thanks for you help!



Jim

Avatar

Former Community Member
Adding more to this.



I found this, with no answer. But this is my problem as well.



I'm trying to connect to a SQL Server DB to automatically fill certain form fields. I can create the connection, but then I am presented with a screen to select the data collection method - either Table, Stored Procedure, or SQL Query. I choose Stored Proc, but when I try to proceed I get the following error:



Stored Procedure has non-optional parameters.



How do I pass the stored procedure the parameter?



Here is my SP

SELECT [Name]

FROM List2

WHERE [File] = @Numb



Thanks!



Jim

Avatar

Former Community Member
Does anyone have a solution to Jim's question? I need to know how to create a variable for a user-entered field, and have that variable be used in a SQL Server 2005 query associated with other fields on the form. In my situation, I chose SQL Query rather than Stored Proc, but the answer should be the same for both methods.

Avatar

Former Community Member
I am working on the same problem, have the same question. It seems like such a simple solution and problem and I am wondering why there is not a response.

Avatar

Level 7
You should be using JavaScript's "switch()" statement.



switch(DropDownList1.rawValue) {

case "One":

$.rawValue = "One";

break;

case "Two":

$.rawValue = "Select 2";

break;

case "Three":

$.rawValue = "3 Selected";

break;

default:

$.rawValue = "None";

break;

}