> Hello Everyone
> I am using wt-3.1.9. I am making  database application based on student
> just enter name and roll number.
> In which show some error. These error are couldent solve by me.  I am
> unable to make the database of any application.
> please visit this application and tell me how to solve the problem.
> please help me
>


source code :-
#include "student.h"

#include <Wt/WApplication>
#include <Wt/WBreak>
#include <Wt/WContainerWidget>
#include <Wt/WText>
#include <Wt/WLineEdit>
#include <Wt/WPushButton>
#include <Wt/WCheckBox>
#include <Wt/WAnchor>
#include <Wt/WImage>
#include <Wt/Dbo/backend/Sqlite3>
#include <Wt/WTemplate>
#include <Wt/WStackedWidget>
#include <Wt/WCssDecorationStyle>
#include <Wt/Dbo/Dbo>
#include <Wt/Dbo/backend/Sqlite3>
#include <Wt/Dbo/QueryModel>
#include <Wt/WTableView>
namespace dbo = Wt::Dbo;
#include <string>
using namespace Wt;

class HelloApplication : public WApplication

{
public:
  HelloApplication(const WEnvironment& env);

private:
WLineEdit *Name;
WLineEdit *rollno;


};
HelloApplication::HelloApplication(Wt::Dbo::Session&, const std::string&,
const Wt::WEnvironment&)
  : WApplication(env)
{
  setTitle("Parvinder");                               // application title
  root()->addWidget(new WText("<h1>This is my officel website</h1>"));
root()->addWidget(new WBreak());
      // WAnchor *x = new WAnchor("http://www.parvinder.co.in";, "Jump to the
middle", root());

   WAnchor *x = new Wt::WAnchor("http://www.parvinder.co.in";, "parvinder",
root());
root()->addWidget(new WBreak());

Wt::WImage *img = new Wt::WImage("/images/pinder3.jpg", root());
 img->setAlternateText("Parvinder");

root()->addWidget(new WBreak());

root()->addWidget(new WText("Name"));  // show some text
  Name = new WLineEdit(root());                     // allow text input
  Name->setFocus();
root()->addWidget(new WText("rollno"));
 rollno = new WLineEdit(root());
rollno->setFocus();
//password->setEchoMode(WLineEdit::Password);

  WPushButton *b = new WPushButton("add", root()); // create a button
  b->setMargin(5, Left);
b->clicked().connect(this, &HelloApplication::root());
//Wt::WWidget *widget =("/images/pinder3.jpg", root());
//widget->decorationStyle().setCursor(PointingHandCursor);


}
template<class Action>
  void persist(Action& a)
  {
    dbo::field(a, Name,     "Name");
    dbo::field(a, rollno, "rollno");
}
void create_database (void)
{
  dbo::Session session;
  dbo::backend::Sqlite3 sqlite3 ("MyDB.sql3");
  session.setConnection (sqlite3);
  session.mapClass<User> ("pinder");

  session.createTables();
{
    dbo::Transaction transaction(session);
User *user = new User();
        user->Name = " " + boost::lexical_cast<std::string>(i);
        user->rollno = " ";
 dbo::ptr<User> userPtr = session.add (user);

      }
    transaction.commit();
  }
}
class mainWindow : public WContainerWidget
{
public:
  mainWindow (dbo::Session & session, WContainerWidget *parent=0)
    : WContainerWidget (parent)
  {
    dbo::QueryModel< dbo::ptr<User> > *model = new dbo::QueryModel<
dbo::ptr<User> >();
    model->setQuery(session.find<User>());
    model->addAllFieldsAsColumns();
 }
};
class MyApplication : public WApplication
{
private:
  dbo::Session session;
  dbo::backend::Sqlite3 sqlite3;
public:
  MyApplication (WEnvironment const & env)
    : WApplication (env), sqlite3 ("MyDB.sql3")
  {
    session.setConnection (sqlite3);
    session.mapClass<User>("user");
 root () -> addWidget (new mainWindow (session, root ()));
  }
  ~MyApplication (void) { std::cout << "MyApplication dead" << std::endl; }
};
WApplication *createApplication(const WEnvironment& env)
{
 return new MyApplication (env);
  return new HelloApplication(env);
}

int main(int argc, char **argv)
{
  create_database ();
  return WRun(argc, argv, &createApplication);
}
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to