craftleft.gif (3002 bytes)QuickTable
Home | API | Tutorial | Download | Support | Contact topblack.gif (108 bytes)


QuickTable User Cp  |  Register  |  Members  |  Search  |  Help
    |- QuickTable Discussion Forums > Column Post New Topic   Post A Reply
Default value on Column printer friendly version
next newest post | next oldest post
Author Messages
aurelio7
Private

Gender: Unspecified
Location:
Registered: Jul 2005
Status: Offline
Posts: 5

Click here to see the profile for aurelio7 Send email to aurelio7 Send private message to aurelio7 Find more posts by aurelio7 Edit or delete this message Reply w/Quote
Posted Wednesday, July 13, 2005 @ 09:18:39  

When I add a row in a dbtable is possible to set default value for the not nullable column (programmaticaly or retrieve the default value from the metadata) ??
Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Wednesday, July 13, 2005 @ 17:30:01  

Have a look at the Customer Order Demo, it explains how to set default values during insert

http://quicktable.org/tutorial/customerOrderDemo.htm

Here is a snippet of the code. For full details refer the above sample

Code:

class MyChangeListener extends DatabaseChangeListener
{

public boolean onNewButtonClick()
{
//order No, is the primary key in this table, we don't want the user to create
//a order number , we want to automatically create a order number , everytime
//user inserts a new record
Vector insertVector = new Vector();

//this is just for example, don't follow this example of creating unique key because it may create duplicates
insertVector.addElement(new Integer(Math.abs(randomOrderNumber.nextInt())));

insertVector.addElement("");

//Float & double doesn't work with simpletext , so used the default string
//usually supply the correct datatype
//insertVector.addElement( new Float(0.0));
insertVector.addElement("");
insertVector.addElement("");
insertVector.addElement("");
insertVector.addElement("");
insertVector.addElement("");
insertVector.addElement("");
insertVector.addElement("");
insertVector.addElement("");
insertVector.addElement("");

try{
dBTable1.insert(insertVector);
}
catch(Exception e)
{
JOptionPane.showMessageDialog( CustomerOrderDemo.this,e.getMessage(),"Error",JOptionPane.OK_OPTION);
}

//since we have already inserted the record, return true, so that
//quicktable doesn't insert the default record
return false;
}

//there are more methods in this class beforeUpdate, afterUpdate, beforeInsert, afterInsert, onDeleteButtonClick
//you can use them too.
}


Post New Topic   Post A Reply Jump to:
Contact Us | QuickTable - A Java DBGrid | Privacy Policy All times are GMT -5 Hours.
Welcome to QuickTable Forums, Guest!  
Login
Username :
Password :
In order to fully utilize the abilities of this board, you are required to register as a member. Registration is free, and allows you to do lots of things including turning on or off certain features of this board. Register now!
Powered by CuteCast v2.0 BETA 2
Copyright © 2001-2003 ArtsCore Studios