Results 1 to 7 of 7
  1. #1
    chyeeqi is offline Member
    Join Date
    Aug 2009
    Posts
    23
    Rep Power
    0

    Default need help in sql statement

    question 1 :

    how can i write sql statement that insert data in table that contain a field with data type auto number??
    eg :
    my reception table contain 2 field
    No and patient
    No 's data type is auto nu,ber
    patient 's data type is text
    how can i write the sql statement????

    question 2 :

    how can i take all the data in the column??
    eg :
    medicine quantity
    a <t> 1
    b 2

    how cna i get all medicine data and save it into array??

  2. #2
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

    Default

    Quote Originally Posted by chyeeqi View Post
    question 1 :

    ..

    question 2 :

    ...

    hallo, do you already have established a connection with the database you want to use? a'm asking, because explaining all the details you need can take very long. so why don't your read this http://www.java-forums.org/java-tuto...nectivity.html first? after ou should be able to insert data in your table.

  3. #3
    chyeeqi is offline Member
    Join Date
    Aug 2009
    Posts
    23
    Rep Power
    0

    Default

    i noe way to connect database..i dunno how to insert data into table which contain autonumber datatype
    eg :
    normally we use tis sql to insert data
    INSERT INTO PATIENT VALUES ("abc","abc")

    but how can i insert data into table which have autonumber data type

  4. #4
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

    Default

    Quote Originally Posted by chyeeqi View Post
    but how can i insert data into table which have autonumber data type

    what are autonumber data type? do you mean auto incremental number? if yes, do not insert the value for this type of data, because your db will increment this number automatically.

  5. #5
    chyeeqi is offline Member
    Join Date
    Aug 2009
    Posts
    23
    Rep Power
    0

    Default

    i had try tis way
    INSERT INTO PATIENT ( Patient ) VALUES ( "abc" )
    but fail.
    1st column is no , data type autonumber
    2nd column is patient , data type text
    Last edited by chyeeqi; 03-28-2010 at 04:42 PM.

  6. #6
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

    Default

    Quote Originally Posted by chyeeqi View Post
    i had try tis way
    INSERT INTO PATIENT ( Patient ) VALUES ( "abc" )
    but fail.
    1st column is no , data type autonumber
    2nd column is patient , data type text

    i don't know which database you use but read the documentation about autonumber for your database.

    in java single quotes are used to wrap strings. to make the sql-code more readable use PreparedStatements. you will find a good documentation is the "Java Tutorials" forum.

  7. #7
    chyeeqi is offline Member
    Join Date
    Aug 2009
    Posts
    23
    Rep Power
    0

Similar Threads

  1. for statement help
    By helpisontheway in forum New To Java
    Replies: 5
    Last Post: 11-14-2009, 05:14 PM
  2. if statement help please!!
    By soc86 in forum New To Java
    Replies: 5
    Last Post: 12-02-2008, 03:56 PM
  3. If statement, please help??
    By soc86 in forum New To Java
    Replies: 5
    Last Post: 11-23-2008, 03:58 PM
  4. Help with if statement
    By carl in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 08:53 AM
  5. Statement or Prepared Statement ?
    By paty in forum JDBC
    Replies: 3
    Last Post: 08-01-2007, 05:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •