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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript and SQL

Status
Not open for further replies.

Tango524

Technical User
Mar 10, 2003
25
0
0
US
Hi guys!

I am having trouble with the lines below- particularly the getString and SQL statement. It gives me error 68- whatever that means. Any clues as to what is wrong? Thanks!

function onLoad()
{
con = DBDriver.getConnection("alias:hrbid");
stmt = con.createStatement("SELECT DISTINCT hrbid_employee.employee_number from hrbid_employee WHERE hrbid_employee.employee_number = 11111");
rs = stmt.executeQuery();
info = rs.getString(hrbid_employee.employee_number)
md = rs.getMetaData();
alert("number : " +info);
}

 
I see nothing wrong with your SQL statement (except I don't quite see the point of it!).

You should post this question in the forum relating to your application. This isn't really a SQL Server problem.

--James
 
Im going to take a wild guess the you need to enclose the number in quotes:

stmt = con.createStatement("SELECT DISTINCT hrbid_employee.employee_number from hrbid_employee WHERE hrbid_employee.employee_number = ''11111''");

Cant hurt to give it a shot.
 
Hi,

There are two things that I would like to point out here:

1) You SQL Statement actually gives you nothing more than what you are already supplying to it as a parameter for WHERE clause.

2) The statement:
info = rs.getString(hrbid_employee.employee_number)
looks buggy.

I feel, it should be
info = rs.getString("hrbid_employee.employee_number");

This is so, because the getString method of java.sql.ResultSet takes 'java.lang.String' as parameter. Which means that when you want to pass the column name and get the value inreturn, you shoould be passing the column name as a String object i.e. the double quotes are mandatory.

---Varada
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top