Can not insert data to MS Access

Hi All,
I have create a table by manual in Access , in which I defined souch fields:
SORTCODE(text type),FOODNAME(text type)..., and then I use follow statement to insert value :
private DefaultTableModel model = new DefaultTableModel();
Vector collectData = new Vector(50,20);
String sqlStatement = "INSERT ������(SORTCODE,FOODNAME,MEASUREUNIT,QUANTITY,UNITPRICE,BUYDATE,SUPPLIER,BUYER,HOTELNUM,HOTELNAME,REMARK) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
try
PreparedStatement insertData = dbConnection.prepareStatement(sqlStatement);
for(int i=0;i<rowsFlag;i++)
for(int j=1;j<cols;j++)
collectData.add(model.getValueAt(i,j));
insertData.setString(1,collectData.get(0).toString());
int update = insertData.executeUpdate(); //an Exception throwed
catch(Exception ex)
ex.printStackTrace();
when run the code , it always reports Access field not correct error , how to solve the problem ?

Hi Liwei,
Apart from what marych said, according to the code you posted, you are only supplying one value to your "PreparedStatement", namely:
insertData.setString(1,collectData.get(0).toString());You need to supply eleven values (in total), since your "sqlStatement" contains eleven question-mark ("?") characters.
Also note that if one of the values you supply is null, then you need to use the "setNull()" method (of "PreparedStatement") and not the "setString()" method.
Hope this helps.
Good Luck,
Avi.

Similar Messages

  • Can not Insert data to Microsoft Access successfully

    I am using Microsoft Access database, and trying to insert some data into a table with a "while" loop, but every time, the last row can not be inserted although the return value of the "executeUpdate()" is 1, can anyone tell what's wrong with that? thank you very much

    http://forums.java.sun.com/thread.jsp?forum=48&thread=147704
    Sounds like it may be the same "glitch"
    Jamie

  • Can not insert Data

    Hi all ;
    when tryiing to call a stored procedure from java session bean ,i am getting this error message:
    [BEA][Oracle JDBC Driver][Oracle]ORA-20000: Records are not inserted into the stagging table
    ORA-06512: at "APPS3_MTNAOL.MTN_INV_MANAGER", line 2529
    ORA-06512: at line 1
    but when i am calling the same stored procedure from sql developper for test ,with the same input data, it is working fine. what can be the issue?

    ORA-20000 is a user-defined Error in the database. Please check with whoever developed the code within your organization on what that means.
    but when i am calling the same stored procedure from sql developper for test ,with the same input data, it is working fine. what can be the issue?Obviously, you are not able to recreate the error from 'sql developer'.
    Edited by: RPuttagunta on Dec 7, 2010 3:06 PM

  • Can not insert/update data from table which is created from view

    Hi all
    I'm using Oracle database 11g
    I've created table from view as the following command:
    Create table table_new as select * from View_Old
    I can insert/update data into table_new by command line.
    But I can not Insert/update data of table_new by SI Oject Browser tool or Oracle SQL Developer tool .(read only)
    Anybody tell me, what's happend? cause?
    Thankyou
    thiensu
    Edited by: user8248216 on May 5, 2011 8:54 PM
    Edited by: user8248216 on May 5, 2011 8:55 PM

    I can insert/update data into table_new by command line.
    But I can not Insert/update data of table_new by SI Oject Browser tool or Oracle SQL Developer tool .(read only)so what is wrong with the GUI tools & why posting to DATABASE forum when that works OK?

  • I can insert data into an access database, but I need to querry the database for specific information. How do I do it?

    I can insert data into an access database, now I need to do some simple querries such as selecting all records that are greater than a certain value or = a certain value. How can I return only the selected records?

    If you don't want to spend any money, then instead of ActiveX, I would recomend LabSQL from Jeffrey Travis. I use it instead of the Connectivity toolkit and have had no problems. Besides being free, you have the advantage of being able to use it with any database. ActiveX ties you to Access and you upgrade your version of Access and find the properties and methods are different, you've got a lot of reprogramming to do.

  • Can not insert null into foreign key issue

    Hi ,
    I am having parent-child relationship table.
    In the child table when I am adding a new record , data is getting inserted with foreign key.
    After insert if I immediately update the same record. Its giving error that can not insert null into foreign key.
    If i click on rollback button I am able to update that record properly.

    Hi ,
    I am having parent-child relationship table.
    In the child table when I am adding a new record , data is getting inserted with foreign key.
    After insert if I immediately update the same record. Its giving error that can not insert null into foreign key.
    If i click on rollback button I am able to update that record properly.

  • I installed a version of Firefox 6.0. in the Russian program, the social network for sending a short message, I can not insert a file in the message field.

    I installed a version of 6.0. In the Russian program of social network My World by sending a short message, I can not insert a file in the message or photo. How do I solve this key problems?

    I need to access Network Solutions website builder too. It isn't compatible with Internet Explorer v9, Chrome v13, or Firefox v5! I believe Firefox v6 is out now. This is a Network Solution's problem. What's involved in rolling back? Can you still get add-ons, plugins, and extensions for such an older version? You can't save your personal preferences can you?

  • How to insert date into ms access database using sql query in servlet

    sir all thing is working well now only tell me how we can insert date into ms access database which is input by user .
    insert into db2(bookname,studentname,date) values('"+bname+"','"+sname+"',date_format)";{code}
    or either the system date is inserted with query .
      plz help me
    thanx                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    bhavishya wrote:
    sir all thing is working well now only tell me how we can insert date into ms access database which is input by user .
    insert into db2(bookname,studentname,date) values('"+bname+"','"+sname+"',date_format)";{code}
    or either the system date is inserted with query .
    plz help me
    thanxAnd that SQL statement is another reason to use PreparedStatement. I assume bname and sname are input from some form? Well, if that's the case, simply inserting them into SQL by simple String concatenation is just begging for all sorts of problems. What if there is an apostrophe in the entry? Broken Statement. Worse, it's a wide open invitation to an SQL Injection attack.

  • BDC not inserting data in mandatory fields of MM01

    Suddenly My BDC for sales maintenance View is not working as it is not inserting data in Mandatory fields.?can any one tell me the reason

    Hi Satyanarayan,
    1. Check ur code in debug to see if your internal table contains value in mandatory fields
    2. Try executing BDC program online to figure out the problem....
    3. Check ur code to see whether u r assigning values to this fields...
    Let me know if these things are ok in ur code...
    Enjoy SAP.

  • A Power User Can Not Send Data  - BPC Release 7.5.112.07 MS

    Hi BPC Community,
    We have a group of users who are able to send data to locked dimensions. We added a new power user and this person can not send data to locked dimensions (see attached screen-shot). The person is checked box as a "leader" in the Teams responsibility.
    Any suggestions?
    Thanks. Barry

    Hi
    Options
    • All = any user with member access write privilege
    • Owner = only users assigned as owner with member access write privilege
    • Mgr = Owner of parent dimension member is manager of child dimension member
    • Locked = no user regardless of authorization.
    Controlled By: Determines who can select the work status code
    • Both = owner of the specific member ID and the owner of the parent to the specific member ID
    • Owner = owner of the specific member ID
    • Mgr = owner of the parent to the specific member ID.
    also go through below link
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/2064bb40-ea48-2e10-069c-cc6878a0f1cc?QuickLink=index&…
    https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=5&cad=rja&uact=8&ved=0CEIQFjAE&url=https%3A%2F%2Fhelp.sa…
    Hope this will help you.
    sushant

  • Can not find data in virtual cube

    Experts,
    I can not find data in virtual cube with services function module (copying Z_RS_BCT_FIGL_DATA_GET_VC10 from RS_BCT_FIGL_DATA_GET_VC10).The standard cube is maintained with data.
    Can anybody tell me what could be the reasons the data is coming through Virtua cube.
    Thanks,
    AK

    Hi,
    i_basic_infoprov is the name of the provider where the data is selected from. This must be a basic provider that contains data. What I meant was, create a copy of fm RS_BCT_FIGL_DATA_GET_VC,1 maybe as Z_BCT_FIGL_DATA_GET_VC1, and enter the name of this fm in the properties of your virtual cube. For that fm it might also be a good idea to enter a default value for i_infoprov. And this should be the name of your virtual cube.
    regards
    Siggi

  • Can we insert data directly in standard table

    hi
    how can we insert data in standard table directly.
    pls reply urgently.

    Hi sapna yes u can insert data to the SAP tables, as shown below...
    use the table mara in the place of m
    REPORT  ZTEST_INSERT.
    TABLES: <m>.
    DATA: wa_m TYPE <m>.
    wa_m-ernam = 'ZTEST'.
    insert into <m> VALUES wa_m.
    if sy-subrc = 0.
      WRITE / 'Records inserted Successfully'.
    ENDIF.
    reward if usefull,
    Vishnu. R
    Edited by: vishnu ramanathan on Sep 18, 2008 2:17 PM

  • Can not receive data 10054

    My version of Essbase is 6.5.1.4. On the server machine it self when I am adding members to outline I get "Can not receive data 10054". To resolve this problem I tried to increase the server page file size but the problem persist.Does anyone know a solution to this problem?SAK

    How exactly are you retrieving data; is it smartview, excel addin, forms, reports etc ?

  • Can not extract data into BW from SQL SERVER

    Dear All,
      I meet a problem to extract data from database(MS SQL Server 2000(sp3)) into BW now and can not extract data into BW ODS, even PSA, In the monitor, display yellow light(0 from 0 record), detail message just display message "data request arranged" "confirmed with: confirmation" in requests(message) step; "missing message: request received" in extract (message)  step; "no data" in processing(data packet) step and so on. but in fact, there are two records in my database test table and DB connection is OK. Even I can extract data from another test oracle database into BW ODS successfully.
       Our BW system has two BW applicaton server and use oracle database. the one application server locates on IBM AIX host. the another one locates on one NT server. the application server on NT server is used for data extration from MS SQL SERVER  database into BW oracle database. and MS SQL SERVER and NT platform application server locate on same one host. DBSL was installed on the NT application server already. and DB connector also was created successfully for MS SQL SERVER and datasource also was generated. DBSL type is Kernel640-WIN-IA32bit-unicode. my BW system is ECC5.0/UNICODE/ORACLE. all table/view/field name of MS SQL server is upcase and have not any specific character. for example: ZDEMO etc.
    wait your help.
    Thanks in advance.
    Billy

    Hi  Ravi,
    Could you help me to get knowledge about the followings:
    approximately how many records    extracting and transfering  from SAP R/3 to BIW  in an organisation. for that how much time  will take .
    How to extract data from  two are three source system  to BIW. Kindly help me with step by step explanation .If any screen shots with documents pls fwd to my ID. "[email protected]"
    Your help highly appreciated.
    Thanks.
    Hema

  • Can not get data from database

    hi all,
        there is a problem ,  when i write like below :
    SELECT * FROM bsis INTO CORRESPONDING FIELDS OF TABLE it_temp
              WHERE bukrs = p_bukrs
                AND hkont = p_hkont.
    p_bukrs , p_hkont are all on the selection screen , and p_bukrs = 1200 another is eq blank. i can not find any data , but with the same condition i can find some data in database , when i debeg i found that p_hkont is initial.
        when i write like this :
    SELECT * FROM bsis INTO CORRESPONDING FIELDS OF TABLE it_temp
              WHERE bukrs = p_bukrs .
    this time i can find the data like the database.
        so , does someone know where the problem is , why i can not get data ?
    kind regards
    kevin

    hi,
    if u r  using bukrs and hkont as parameters in selection screen then
    SELECT * FROM bsis INTO CORRESPONDING FIELDS OF TABLE it_temp
    WHERE bukrs = p_bukrs
    AND hkont = p_hkont.
    this will work.
    if u r using then as select-option then the above does n't work.
    bcoz select-options work as internal table bcoz of that u have use the query like this
    SELECT * FROM bsis INTO CORRESPONDING FIELDS OF TABLE it_temp
    WHERE bukrs IN p_bukrs
    AND hkont IN p_hkont.
    <REMOVED BY MODERATOR - REQUEST OR OFFER POINTS ARE FORBIDDEN>
    Edited by: Alvaro Tejada Galindo on Aug 15, 2008 5:25 PM

Maybe you are looking for