• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

incompatible types

 
Mayura Hayat
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello i am trying to take value from textbox and convert it into integer.
i have used the code that is mentioned in this thread but i am receiving an error as incompatible types

code:



can you tel me where i am going wrong?
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12101
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have split your post into its own thread. It's better to create your own original one than to hijack a five year old one.

Also, it's a good idea to post the full and complete error message. It is probably telling you exactly what is wrong. on line 6 of your code, you have an integer ARRAY on the left side, and an int on the right side. you can't do that.

if you just want the value, then take out the "[]"

int psage = Integer.parseInt(sl[i]);

if you need to store more than one and really do need the array, you need to a) first declare the array outside the loop with a size, and b) indicate which slot in the array you want to store your int.
 
Mayura Hayat
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fred thank you very much ....your reply made me think once again over my block of code and i got my mistake.

the error was in line 6 as pointed by you.
Now i am able to insert the data into the database.
i would like to share the code that will help to insert multiple rows into the database using textboxes with same names i.e txtpsngrnm,psngrsex,psngrage are the names of the textboxes.


stmt.executeQuery("insert into fbook(fbid,fpname,fpage,fpgender) values('"+j+"','"+pname[j] +"','"+psage[j]+"','"+pgender[j]+"')");


Thank You All for your help
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic