The code below explains itself and is correct
but everytime i run it a Nullreference error is thrown
Please help me find the object withe property set to null.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Volante;
namespace Dataverse
{
public partial class fill_in_form : Form
{
public fill_in_form()
{
InitializeComponent();
}
public long insertedCount;
public class fields_to_fill : Volante.Persistent
{
public string STU_Firstname;
public string STU_Lastname;
public Int64 STU_Age;
public string STU_gender;
public string STU_school;
public string G_firstname;
public string G_lastname;
public Int64 G_contact;
public string G_Occupation;
public Image STU_pic;
}
public class databaseroot : Persistent
{ public IIndex<string,> Fisrtname;
public IIndex<string,fields_to_fill>Lastname;
public IIndex<int64,> Age;
public IIndex<string,> gender;
public IIndex<string,> school;
public IIndex<string,> G_firstname;
public IIndex<string,> G_lastname;
public IIndex<int64,> G_contact;
public IIndex<string,> Occupation;
public IIndex<Image, fields_to_fill> Stu_pic;
}
databaseroot DVdbrootobject = new databaseroot();
private void fill_in_form_Load(object sender, EventArgs e)
{
IDatabase db = DatabaseFactory.CreateDatabase();
progressBar1.PerformStep();
if (progressBar1.Maximum <= 100)
{
db.Open("fileinfo.dbs");
MessageBox.Show("Database Opened", "Dataverse");
}
if (null != db.Root)
{
DVdbrootobject = (databaseroot)db.Root;
}
else
{
DVdbrootobject = new databaseroot();
DVdbrootobject.Fisrtname = db.CreateIndex<string,>(IndexType.NonUnique);
DVdbrootobject.Lastname = db.CreateIndex<string,>(IndexType.NonUnique);
DVdbrootobject.Age = db.CreateIndex<int64,>(IndexType.NonUnique);
DVdbrootobject.gender = db.CreateIndex<string,>(IndexType.NonUnique);
DVdbrootobject.school = db.CreateIndex<string,>(IndexType.NonUnique);
DVdbrootobject.G_firstname = db.CreateIndex<string,>(IndexType.NonUnique);
DVdbrootobject.G_lastname = db.CreateIndex<string,>(IndexType.NonUnique);
DVdbrootobject.G_contact = db.CreateIndex<int64,>(IndexType.NonUnique);
DVdbrootobject.Occupation = db.CreateIndex<string,>(IndexType.NonUnique);
DVdbrootobject.Stu_pic = db.CreateIndex<Image, fields_to_fill>(IndexType.Unique);
db.Root = DVdbrootobject;
db.Commit();
}
}
private void button2_Click(object sender, EventArgs e)
{
STU_Datafill();
}
public void STU_Datafill()
{
var enter = new fields_to_fill();
DVdbrootobject = new databaseroot();
fields_to_fill givefield = new fields_to_fill();
FirstnameTB.Text = givefield.STU_Firstname;
LastnameTB.Text = givefield.STU_Lastname;
AgeTB.Text = givefield.STU_Age.ToString();
SchoolTB.Text = givefield.STU_school;
GfirstnameTB.Text = givefield.G_firstname;
GlastnameTB.Text = givefield.G_lastname;
GcontactTB.Text = givefield.G_contact.ToString();
GoccupTB.Text = givefield.G_Occupation;
DVdbrootobject.Fisrtname.Put(enter.STU_Firstname, enter);
DVdbrootobject.Lastname.Put(enter.STU_Lastname, enter);
DVdbrootobject.Age.Put(enter.STU_Age, enter);
DVdbrootobject.school.Put(enter.STU_school, enter);
DVdbrootobject.G_firstname.Put(enter.G_firstname, enter);
DVdbrootobject.G_lastname.Put(enter.G_lastname, enter);
DVdbrootobject.G_contact.Put(enter.G_contact, enter);
DVdbrootobject.Occupation.Put(enter.G_Occupation, enter);
IDatabase db = DatabaseFactory.CreateDatabase();
if (insertedCount % 10000 == 0)
{
db.Commit();
}
}
}
}
Im working with volante.dll
its an embeddable database engine created for speed
[edit]Code block added - OriginalGriff[/edit]