cancel
Showing results for 
Search instead for 
Did you mean: 

SQL- 2005 : User Input in select statement's where cond [Input Parameter]

Former Member
0 Kudos

Hi All

i am using SQL Server 2005 , i want to select the data based on the user input in where condition,

but i am not sure what to give in where condition,can anyone have any idea on this

SELECT [NO]
      ,[NAME]
      ,[PAGE_COUNT]
  FROM [DS].[DB].[tablename]
where [NO]=???

Regards

Chaitanya.A

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Which software are you using to interface to SQL server?

Former Member
0 Kudos

HI

public String getEmployeeName(String employeeNumber) 
	{
		// TODO : Implement
		String name = new String();
		String exception = new String();
		try 
		{
		InitialContext initialContext = new InitialContext();
		DataSource dataSource =(DataSource) initialContext.lookup("jdbc/XXXX");
		java.sql.Connection connection = dataSource.getConnection();
		PreparedStatement stmt =connection.prepareStatement("SELECT [NAME]FROM [XXX].[ASDF].[ABCD] where [NO]=?");
		stmt.setString(1,employeeNumber);
		ResultSet result = stmt.executeQuery();
		while (result.next()) 
			{
			name = result.getString("Name");
			}
			connection.close();
			return name;
		}
		catch (Exception e) 
		{
			exception = "Exception";
			return exception;
		}
	}

i used the above function to achieve my requirement

Thanks

Chaitanya.A

Answers (0)