Click to See Complete Forum and Search --> : editable sql table in java + some questions


kheiremans
01-10-2007, 02:49 AM
Hi

i'm working on a project and I have to display records from an sql table(no problem) but i'd like them to be easily editable from within that page. I remember this being very easy when I used asp(long time ago).

e.g. bla bla bla bla bla bla [edit/del button which takes u to edit page with the fields already holding current data]
............................... []
............................... []
............................... []
............................... []
[insert button which takes u to page with empty fields]






But how can I do this with myeclipse and java. Is it built in or do I have to code it myself(and what would be the best aproach)

So far I am only using html and servlets. The DB is running on my microsoft SQL 2005 server

A 2nd question i'm having. I have a form with a checkbox and a boolen field in sql 2005. Does it accept the values standard generated from the checkbox when i use bit as type

A 3rd question: i'm fetching data from multiple textfields (23 to be precise)
request.getParameter("textfield1");
....
request.getParameter("textField23");

can i loop this in any way?


thanks in advance

agent_x91
01-10-2007, 04:48 AM
i'm fetching data from multiple textfields (23 to be precise)
request.getParameter("textfield1");
....
request.getParameter("textField23");

can i loop this in any way?


thanks in advance

Why not use a for loop?


for(int i=0;i<=23;i++)
request.getParameter("textfield"+i);

kheiremans
01-10-2007, 05:12 AM
This was my code but it didn't work

Boolean Check[] = new Boolean[23];

for(int i=0; i<23;i++){

checkbox = ("checkbox" + (i+1));
Check[i] = Boolean.parseBoolean(request.getParameter(checkbox));

if(Check[i] == null){
Check[i] = false;//database needs a boolean, null is illegal value
//(unchecked checkbox returns null)
}//end if
}//end for

kheiremans
01-11-2007, 04:14 AM
thanks for the help


i started to code the delete.

now i'm ahving a problem:

fetching the records from the db is no problem but then i either have to add a button at the end of each row:

for (int i = 1; i <= cols; i++){
out.println("<TH>" + rsMeta.getColumnLabel(i) + "</TH>");
}
out.println("</TR>");
while(rs.next()){
out.println("<TR>");
int invtemp;
for (int i = 1; i <= cols; i++){
if(i == 1){
invtemp = (Integer.parseInt(rs.getString(i)));
}
out.println("<TD>" + rs.getString(i) + "</TD>");
}
out.println("<input type=\"button\" value=\"DELETE\" name=\"button1\" onClick="delrecord(invtemp)" \"> ");//delrecord is a method that executes a delete query
out.println("</TR>");
}

but i don't know how i can make the button to actually execute the method delrecord. any1 who can help me out?

or i have to be able to let the servlet only fetch the data but not display it. But i have no idea how to do this