Web form not updating database with stored procedure

Hello
i have a problem with the web form updating the database i have a stored procedure which i need to connect to. If i execute the procedure in the SQL it will update the database but when i run the web form i get my catch error "could not update database".
I have read so much on the net and my code seem ok but i,m just so lost.
stored procedure
PROCEDURE [dbo].[UpdateCustomer]
@ID INT,
@Firstname VARCHAR(30),
@Surname VARCHAR(30),
@Age INT
AS
BEGIN
UPDATE Customer
SET Firstname = @Firstname,
Surname = @Surname,
Age = @Age
WHERE CustID = @ID
END
update code
try
SqlCommand command = new SqlCommand();
command.Connection = conn;
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "UpdateCustomer";
command.Connection.Open();
SqlParameter param = new SqlParameter();
param.ParameterName = "@ID";
param.SqlDbType = SqlDbType.Int;
param.Direction = ParameterDirection.Input;
param.Value = txtCustID.Text;
command.Parameters.Add(param);
command.Parameters.AddWithValue("@CustID", txtCustID.Text.ToString());
command.Parameters.AddWithValue("@Firstname", txtFirstname.Text);
command.Parameters.AddWithValue("@Surname", txtSurname.Text);
command.Parameters.AddWithValue("@Gender", Gender.Text.ToString());
command.Parameters.AddWithValue("@Age" ,txtAge.Text.ToString());
command.Parameters.AddWithValue("@Address1", txtAddress1.Text.ToString());
command.Parameters.AddWithValue("@Address2", txtAddress2.Text.ToString());
command.Parameters.AddWithValue("@City", txtCity.Text.ToString());
command.Parameters.AddWithValue("@Phone", txtPhone.Text.ToString());
command.Parameters.AddWithValue("@Mobile", txtMobile.Text.ToString());
command.Parameters.AddWithValue("@Email", txtEmail.Text.ToString());
command.ExecuteNonQuery();
lblMessage.Text = "Your Record(s) Have been Updated";
command.Connection.Close();
catch
lblMessage.Text = "Your Record was not updated please try again";
Thank you for your help

To expand on Mike's advice.
Change your catch to:
catch(Exception ex)
{ // Break point here
lblMessage.Text = "Your Record was not updated please try again";
Put a break point in where the comment says.
Run it.
Hover over ex or add a quickwatch ( right click it ) and see what the error and inner exception is.
I see several problems though.
You have way too many parameters and Age should be int.
They are objects  - they have a type.
It'll be a string with your code there.
Something more like
command.Parameters.Add("@Age", SqlDbType.Int);
command.Parameters["@Age"].Value = Convert.ToInt32(txtAge.Text);
Although that might not cut and paste, it's air code intended to give you the idea.
Hope that helps.
Technet articles: Uneventful MVVM;
All my Technet Articles

Similar Messages

  • Is BC4J a viabl option for database with stored procedure (ref cursor) API?

    I'm about to begin a Web application development project. As foundation, we have a (Oracle) database of certain complexity that have a data access API developed with PL/SQL packages.
    This API is designed to get data through stored procedures/functions that return REF CURSOR.
    Personally I have been investigating about Oracle ADF/JSF, and a number of others J2EE technologies, and at this moment I am doubting if ADF BC are a viable option to my development team.
    I think this because I have noticed that one of the great drawback in ADF BC is the lack of simplicity to get data through stored procedures/functions that returns REF CURSORS.
    I have been looking for documentation and the only thing that I have found are two examples:
    1.- One that really do not work (fails in get data from ref cursor): ADF BC StoredProcedure Sample application.
    2.- And other published by Steve Muench in
    http://radio.weblogs.com/0118231/stories/2003/03/03/gettingAViewObjectsResultRowsFromARefCursor.html. This sample works fine.
    But, the problem with the approach of this last article is the amount (and complexity) of the code necessary to make so basic and recurrent operation as is "obtain data through a stored procedure (ref cursor)".
    Below it is the code that I have constructed to call a function that returns a ref cursor (based on steve's article).
    If this is the only way to make this (historically so basic and simple) task, then it is obvious that BC is not a viable technology to my (or I am in a mistake?), since we have about 50 stored procedures/functions to access the underlying data; that stored procedures/functions are key to development of the new application (and, still more, currently are used to anothers apps ).
    By all this, I would like consult to Oracle's people:
    1.- I really must reject BC as technology to implement this project ?
    2.- It is possible to access stored procedures in a simpler way using BC?
    3.- If the answer to 2 is NOT: in near future, the BC team has plans to give more support to the simple access to stored procedures?
    4.- If the answer to 3 is NOT: what another technology you recommend to construct my data access/business tier and still be able to using the others characteristics of ADF?
    Thank you very much for your guidelines.
    Regards, RL.
    ** And the code!!!
    ** ###   I am forced to do this for each call to a procedure???? ###
    package myrefcursor.model;
    import java.math.BigDecimal;
    import java.sql.CallableStatement;
    import java.sql.ResultSet;
    import java.sql.ResultSetMetaData;
    import java.sql.SQLException;
    import java.sql.Types;
    import oracle.jbo.JboException;
    import oracle.jbo.domain.NullValue;
    import oracle.jbo.domain.Number;
    import oracle.jbo.server.DBTransaction;
    import oracle.jbo.server.ViewObjectImpl;
    import oracle.jbo.server.ViewRowImpl;
    import oracle.jbo.server.ViewRowSetImpl;
    import oracle.jdbc.driver.OracleCallableStatement;
    import oracle.jdbc.driver.OracleTypes;
    public class TraePolizasViewImpl extends ViewObjectImpl {
        private static final String SQL = "begin ? := PKG_PRUEBA.trae_polizas(?);end;";
        private static final String COUNTSQL = "begin ? := PKG_PRUEBA.count_trae_polizas(?);end;";
        public TraePolizasViewImpl() {
        protected void executeQueryForCollection(Object qc,Object[] params,int numUserParams) {
            BigDecimal rut_contratante = null;
            Object[] theUserParam = null;
            System.out.println(params);
            System.out.println(params[0]);
            if (params != null)
                theUserParam = (Object[]) params[0];
            //if (theUserParam != null && theUserParam.length > 0 )
            if (! (theUserParam[1]   instanceof NullValue) )
                rut_contratante = (BigDecimal)theUserParam[1];
            storeNewResultSet(qc ,retrieveRefCursor(qc, rut_contratante));
            super.executeQueryForCollection(qc, params, numUserParams);
        protected void create() {
          getViewDef().setQuery(null);
          getViewDef().setSelectClause(null);
          setQuery(null);
        protected ViewRowImpl createRowFromResultSet(Object qc, ResultSet rs) {
          rs = getResultSet(qc);
          ViewRowImpl r = createNewRowForCollection(qc);
          try {
            populateAttributeForRow(r,0, nullOrNewNumber(rs.getBigDecimal(1)));
            populateAttributeForRow(r,1, rs.getString(2));
          catch (SQLException s) {
           throw new JboException(s);
          return r;
        protected boolean hasNextForCollection(Object qc) {
          ResultSet rs = getResultSet(qc);
          boolean nextOne = false;
          try {
            nextOne = rs.next();
            if (!nextOne) {
              setFetchCompleteForCollection(qc, true);
              rs.close();
          catch (SQLException s) {
           throw new JboException(s);
          return nextOne;
        protected void releaseUserDataForCollection(Object qc, Object rs) {
           ResultSet userDataRS = getResultSet(qc);
           if (userDataRS != null) {
            try {    userDataRS.close();    }
            catch (SQLException s) { ; }  
          super.releaseUserDataForCollection(qc, rs);
        public long getQueryHitCount(ViewRowSetImpl viewRowSet) {
          return viewRowSet.getRowCount();
        private ResultSet retrieveRefCursor(Object qc, BigDecimal rut_contratante) {
          CallableStatement st = null;
          try {
            st = getDBTransaction().createCallableStatement(SQL, DBTransaction.DEFAULT);
            st.registerOutParameter(1,OracleTypes.CURSOR);
            if (rut_contratante == null)
                st.setNull(2, Types.NUMERIC);
            else
                st.setBigDecimal(2, rut_contratante);
            st.execute();
            ResultSet rs = ((OracleCallableStatement)st).getCursor(1);
            rs.setFetchSize(getFetchSize());
            return rs ;
          catch (SQLException s) {
            throw new JboException(s);
          finally {try {st.close();} catch (SQLException s) {;}}
        private void storeNewResultSet(Object qc, ResultSet rs) {
          ResultSet existingRs = getResultSet(qc);
          if (existingRs != null) {
            try {existingRs.close();} catch (SQLException s) {;}  
          setUserDataForCollection(qc,rs);
          hasNextForCollection(qc); // Prime the pump with the first row.
        private ResultSet getResultSet(Object qc) {
            return (ResultSet)getUserDataForCollection(qc);
        private static Number nullOrNewNumber(BigDecimal b) {
             try {
               return b != null ? new Number(b) : null;
             catch (SQLException s) { ; }
             return null;
        public BigDecimal getprutcontratante() {
            return (BigDecimal)getNamedWhereClauseParam("prutcontratante");
        public void setprutcontratante(BigDecimal value) {
            setNamedWhereClauseParam("prutcontratante", value);
    }

    no?

  • Link to form with stored procedure

    Hi all,
    We want to have a report with a link that goes to a form that updates using a stored procedure.
    The update form has to get the recent data (not the data from the report).
    To do this we want to pass the id parameter and with that get the rest of the fields from the table.
    Does somebody know how to do this?
    TIA,
    Igor & Eric

    Create a report.
    Create a form based on procedure.
    Create a link based on the above form.
    Attach this like to the report Id column.
    Now edit this link and supply the value for ID (Select the column) for the corresponding form field.
    Thanx,
    chetan.

  • Forms Data-Block based on stored procedures - REF CURSOR feature NOT FUNCTIONING

    This topic is related to another topic in this forum titled "FORMS HOW TO SET QUERY SOURCE ARGUMENTS??" I posted my message there as well. I am posting as a NEW TOPIC so that it catches the attention of Oracle Support.
    I built a data form based on a stored procedure and REF CURSOR IN OUT parameter.
    My procedure takes a IN parameter to fill in the criteria for the OPEN <cursor_variable> select ... where ... statement.
    In the Value setting of the Query source Arguments , I set the VALUE to ":BLOCK_NAME.ITEM_NAME" at design time to supply the input value to the procedure. this works to the extent of making available the form item value to the stored procedure parameter. I verified this by doing an insert into some debug table , of the incoming parameter value inside my stored procedure.
    The cursor gets opened properly into the REF cursor variable. I verified this by fetching a record into a local variable and inserting the value into a debug table again in the stored procedure.
    (I took care to close and re-open the REF cursor variable again - so that the front-end can continue to fetch it from the first record. )
    ***** PROBLEM **************
    But the front end forms runtime is giving me a FRM-40301 - query returned no records even though the REF cursor is returned properly opened.
    Did anybody else face the same problem ??
    Please post what you found.
    Thanks,
    Shankaran
    null

    This topic is discussed at length in another thread "How Set Value For Query DataSource Arguments?"
    But I am posting the findings here as well.
    THIS TOPIC IS CLOSED.
    My Bad. The problem Cause : I did not include all columns in the
    cursor rowtype in the Data-block. In the wizard for the data block , I selected ONLY the columns that I needed. But I was doing a Select * from <my_table> in my open cursor <Cursor-Variable> .... The <Cursor Variable>
    itself was declared <my_table>%rowtype
    FIX : The Data Block structure (columns included as items) should match the cursor record Structure. One may or may not
    display all the columns in the LAYOUT though.
    But I don't understand why it gives such a misleading message like FRM-40301 Query retrieved no records. Oracle Team fix it.
    Hope this helps people who face the same problem.
    Thanks,

  • Toplink with stored procedures

    Hi
    I am new to Toplink and would like to get an idea whether Toplink would be suitable for our application. Currently, in our application we always access the database through stored procedures. I realize Toplink supports stored procuedres with StoredProcedureCall class. However; I am just trying to get some feedback as to whether using only this feature(as well as handling database connections etc.) of Toplink is a good idea or not.
    Thanks,
    Izi

    I have my entity manager setup in a singleton.
    I'm finding it's costly to generate the emf, but if I don't close the em (enitity manager) and emf (entity manager factory) my open cursor count climbs until I exceed the max number of open cursors on the database (11g RAC)
    I'm committing the connection, and uow, and closing the em at the end of each call.
    But until I close the emf, the open cursors aren't released.
    TransactionhistoryPkg tranPkg = new TransactionhistoryPkg(conn); //Class created over database package via JPublisher
    tranPkg.transactionhistoryInsSp(insertTrans.getCardId()); // executes db package
    tranPkg.closeConnection();
    conn.commit();
    uow.commit();
    uow.getAccessor().decrementCallCount();
    em.close();
    Am I missing something really obvious here??
    btw - I found this link helpful in troubleshooting the max cursors issue: https://support.bea.com/application_content/product_portlets/support_patterns/wls/InvestigatingORA-1000MaximumOpenCursorsExceededPattern.html

  • Sending Long Raw Data to Oracle database through Stored  Procedure

    Hi,
    I am trying to push data to Oracle 9i database through Stored Procedure via thin driver. It is going smoothly upto 29411 bytes. But it is not accepting for 53843 bytes and giving following error :
    java.sql.SQLException: Data size bigger than max size for this type: 53843
    Is it thin driver limitation? Can I solve it by using OCI driver? Or is there any other approach?
    I tried creating connection pool in weblogic 7.0 through OCI driver. But I am not able to configure it. Is there any special way of configuration.
    Quick response will be greatly appreciated.
    Thanks
    Sanjiv

    It happens to me. But I am using CMP of Weblogic 7. If you write your own jdbc code, the following link may be helpful.
    http://otn.oracle.com/sample_code/tech/java/codesnippet/xmldb/HowToLoadLargeXML.html

  • ERROR 2009-05-24 08:46:36 CJS-00288 Could not update database statistics.

    Hi all.
    i am in the middle of SAP ECC 5.0 installation .In the Database instance installation at the step 29 database update statistics, system stops giving error
    ERROR 2009-05-24 08:46:44
    CJS-00288  Could not update database statistics.<br>
    DIAGNOSIS: Command brconnect -u / -c -f crsyn -o SAPDB5 returned 3.<br>SOLUTION: See brconnect.log for details.
    when i checked in brconnect.log i found below error message
    BR0801I BRCONNECT 7.00 (16)
    BR0999E Loading of SQL client library oci.dll failed - please check Oracle configuration
    BR0310E Connect to database instance DB5 failed
    BR0280I BRCONNECT time stamp: 2009-05-24 08.46.44
    BR0804I BRCONNECT terminated with errors
    Q))Which oracle version are you using since BRTOOLS 7.0 is designed to work with Oracle 10g?
    If you are using an oracle 9.2.* it is needed to install oracle instant client or to downgrade your db tools (brt* tools)...... Through :Forums I came to know that we have to downgrade the br*tools to
    Could you please help me how to downgrade the Brtools or could you please suggest me how to proceed
    please help me
    Thanks
    Senthil

    Hi All,
    Thanks for your help, that error it has passed but now in 31 st step starting RFC jobs
    i get this error
    ERROR 2009-05-25 18:08:05
    FRF-00007  Unable to open RFC connection.
    ERROR 2009-05-25 18:08:05
    FRF-00063  RFC logon failed with message: Failed: SAP_CMINIT3 : rc=20 > Connect to SAP gateway failedConnect_PM  GWHOST=CTSINSAPEC5, GWSERV=sapgw00, ASHOST=CTSINSAPEC5, SYSNR=00
    but early during the last error update database statistics the SAP MMC console was up and running but now SAP is down during this error
    i tried to start SAP manually but it never works dispatcher goes down, i searched in forums and thought to update the kernal, so i updated the kernal also and tried it then also same error
    please help me my situation is very pathatic, i will be greatful if you help me
    Thanks
    Senthil

  • ERROR 2008-04-30 09:10:35 CJS-00288 Could not update database statistics.

    Hi Gurus..
    Hi i am in the middle of NW 2004  installation . At the step 29 database update statistics, system stops giving error
    ERROR 2008-04-30 09:10:35
    CJS-00288 Could not update database statistics.
    DIAGNOSIS: Command brconnect -u / -c -f crsyn -o SAPP47 returned
    3.SOLUTION: See brconnect.log for details.
    When i checked in brconnect.log i found below error message
    BR0801I BRCONNECT 7.00 (16)
    BR0999E Loading of SQL client library oci.dll failed - please check Oracle configuration
    BR0310E Connect to database instance P47 failed
    BR0280I BRCONNECT time stamp: 2008-04-30 09.10.35
    BR0804I BRCONNECT terminated with errors
    Q))Which oracle version are you using since BRTOOLS 7.0 is desinged to work with Oracle 10g?
    If you are using an oracle 9.2.* it is needed to install oracle instantclient or to downgrade your db tools (brt* tools)......  Through :Forums I came to know that we have to downgrade  the br*tools to
    Could you please help me how to downgrade the Brtools.
    It's urgent.
    Points will be awarded .
    Regards
    Jan.

    Hi janakiram
    Now i am facing the same error which you have faced before, have you solved that issue if it so could you pls help me how to solve this
    Hi All,
    i am in the middle of SAP ECC 5.0 installation .In the Database instance installation at the step 29 database update statistics, system stops giving error
    ERROR 2009-05-24 08:46:44
    CJS-00288 Could not update database statistics.
    DIAGNOSIS: Command brconnect -u / -c -f crsyn -o SAPDB5 returned 3.
    SOLUTION: See brconnect.log for details.
    when i checked in brconnect.log i found below error message
    BR0801I BRCONNECT 7.00 (16)
    BR0999E Loading of SQL client library oci.dll failed - please check Oracle configuration
    BR0310E Connect to database instance DB5 failed
    BR0280I BRCONNECT time stamp: 2009-05-24 08.46.44
    BR0804I BRCONNECT terminated with errors
    Q))Which oracle version are you using since BRTOOLS 7.0 is designed to work with Oracle 10g?
    If you are using an oracle 9.2.* it is needed to install oracle instant client or to downgrade your db tools (brt* tools)...... Through :Forums I came to know that we have to downgrade the br*tools to
    Could you please help me how to downgrade the Brtools or could you please suggest me how to proceed
    please help me
    Thanks
    Senthil

  • Could not update database error while installation

    Hi i am in the middle of 4.7 installation (IDES). At the step 29 database update statistics, system stops giving error
    ERROR 2008-04-30 09:10:35
    CJS-00288  Could not update database statistics.
    <br>DIAGNOSIS: Command brconnect -u / -c -f crsyn -o SAPP47 returned
    3.<br>SOLUTION: See brconnect.log for details.
    Can anybody tell what could be the problem.
    Thanks in advance

    Hi
    Thanks for your reply. Following are the details of file brconnect.log:
    BR0801I BRCONNECT 7.00 (16)
    BR0999E Loading of SQL client library oci.dll failed - please check Oracle configuration
    BR0310E Connect to database instance P47 failed
    BR0280I BRCONNECT time stamp: 2008-04-30 09.10.35
    BR0804I BRCONNECT terminated with errors

  • TA25361 I have a ton of documents and databases in AppleWorks v 6.0 that I can no longer open on my MacBook Pro.  Is there any way to recover this info?  Some documents can be opened and resaved with textedit, but not my database with all important addres

    I have a ton of documents and databases in AppleWorks v 6.0 that I can no longer open on my MacBook Pro.  Is there any way to recover this info?  Some documents can be opened and resaved with textedit, but not my database with all important addresses.

    I tried Peggy's List > Select All > Copy > Paste into an AW spreadsheet suggestion.
    In my case, pasting into the spreadsheet lost all text formatting (mostly text set to bold). The results of formulas were pasted, and checkboxes were pasted as "on" or "off". The DB did not contain any pop-up menus or radio buttons, but I expect they would transfer as a number showing the list position of the chosen item.
    Pasting the copied List view data into a Numbers table gave a result similar to that with AppleWorks. I selected B2 as the target cell (for top left cell of the pasted data) to avoid any effects of posting into a header row or column. Bold and regular text formatting looked the same as it had in AW's List view.
    Based on that, I'd slip the 'paste into an AppleWorks Spreadsheet step, and paste directly into a Numbers Table.
    Regards,
    Barry

  • Problem With Stored Procedure

    Post Author: Ranjith.403
    CA Forum: General
    Hi,
    Am new to crystal reports with stored procedures
    am created a report using a stored procedure in oracle. In that Stored Procedure am Using a temporary table.
    After inserting values into the table am assigning to ref cursor.
    Refcursor having fields like item,onhandstock,purchase rate
    This report working fine in oracle version 9.2.0.1.0 where comes to oracle version 9.2.0.8.0 it's giving the varchar values correctly.
    The Number values are showing as 0.
    Help me to solve it.
    Thanks in Advance,
    Ranjith

    Try modularising this large procedure into smaller procedures and functions, and determine which part is causing you trouble.

  • HT5181 iPhoto for iOS: Photos in iphoto's Camera Roll folder are not updated automatically with edits from other programs

    How can I solve the problem în the subject?

    How can I solve the problem în the subject?
    What exactly are you trying to do?
    Have you been editing photos in iPhoto and want to add them to your camera rool or photo stream?
    Then do exactly as the article describes, that you lonked to:
    iPhoto for iOS: Photos in Camera Roll are not updated automatically with edits from iPhoto
    Use iPhoto's Sharing to save a copy of the edited photo to the Caera Roll, or explain on mor e detail, what you want to do.
    Regards
    Léonie

  • Could I export and import my oracle database via Stored Procedure???

    Hi all,
    I need to export my database using stored procedure, the stored procedure will be called by java application and it works well
    Now I still get the "BIG QUESTION", could I export and import database using stored procedure???
    Really thanks for the response.
    Regards,
    Kahlil

    Hi,
    I think you can use DBMS_DATAPUMP (10.1+), see [DBMS_DATAPUMP|http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28419/d_datpmp.htm#i1007277], for examples see [http://www.psoug.org/reference/dbms_datapump.html]
    Regards,

  • Open other database in stored procedure

    Hi All,
    Im going to open other database in stored procedure.
    Can anyone help me? Thanks

    You cannot open or connect in plsql procedure, but can use database link.
    Documents:
    http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14231/ds_admin.htm#ADMIN029
    http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_5005.htm#i2061505
    Message was edited by:
    ushitaki

  • HT204053 My devices, iPad and iPhone, are not updating automatically with pages.  Any suggestions. They use to about one week ago.

    My devices, iPad and iPhone, are not updating automatically with pages.  Any suggestions. They use to update beautifully about one week ago.  I took my MacBook Pro to the Apple store for software issues, and I been having updating issues.  Little help please.....

    Welcome to the Apple community.
    Check all your devices still have documents and data syncing turned on in settings > iCloud and that iCloud is enabled at settings > Pages. If this doesn't help, reset documents & Data from a computer at...
    iCloud.com

Maybe you are looking for

  • Need code for mobile browser detection

    So I've read there are several different ways to do this using HTML, JS, PHP, Cookies, etc... and found a discussion suggesting to search for "javascript detect mobile browser" which I did, and maybe since the forum is from 2010 the search results ar

  • Trouble with adding images from database

    So I have created this nice little table and want to populate it with an test row and I cant seam to get it to work. I have neber delt with BLOB before and maybe its with that. Well here is the sql code that I am using CREATE TABLE Product (name VARC

  • ITUNES causes my pc to shut down

    Whenever Itunes is running no matter what I'm doing, my computer shuts down and I uploaded the newest version and it still does it. Anyone out there able to help me figure it out? It is VERY annoying. Thank you

  • Why size of archive log file increasing in merge clause

    my database is running in archive log mode. someone is running oracle merge statement. still it is running. He will issue commit after the operation. in that period redolog file increasing now. my question is why size of archive log file increasing w

  • Authentication & Authorization Component

    hi! please introduce to me components for Authentication & Authorization that i use in the web application and i use it for Authentication & Authorization plesae help me . thanks.....