• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

incompatible types

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
a wee bit from the empire
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic