Israel

Israel

  • 707
  • 1.3k
  • 217.9k

I cannot save

Apr 27 2014 5:12 PM
Hi!
 
When I am trying to save I receive this message:
 Object reference not set to an instance of an object.
 
Please have a look to my whole code:
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
//using System.Data;
using System.Data.SqlClient;
namespace ElSoft_FactuStocks
{
public partial class Facturacao : Form
{
public Facturacao()
{
InitializeComponent();
}
//DataRowView drv;
System.Data.SqlServerCe.SqlCeConnection con;
System.Data.SqlServerCe.SqlCeDataAdapter da;
System.Data.SqlServerCe.SqlCeCommandBuilder cb;
DataSet ds1;
int MaxRows = 0;
int inc = 0; 
 
private void btnSave_Facturacao_Click(object sender, EventArgs e)
{
DataRow dRow = ds1.Tables["facturacao"].NewRow();
dRow[1] = label10.Text;
/*dRow[1] = nomeClienteFactu.Text;
dRow[2] = artigoFactu.Text;
dRow[3] = leituraCodFactu.Text;
dRow[4] = quantidadeFactu.Text;
dRow[5] = precoFactu.Text;
dRow[6] = totalFactu.Text;*/
//dRow[7] = quantidadeFactu.Text;
//dRow[8] = quantidadeFactu.Text;
ds1.Tables["Facturacao"].Rows.Add(dRow);
System.Data.SqlServerCe.SqlCeCommandBuilder cb;
cb = new System.Data.SqlServerCe.SqlCeCommandBuilder(da);
cb.DataAdapter.Update(ds1.Tables["Facturacao"]);
MaxRows = MaxRows + 1;
inc = MaxRows - 1;
//btnAddNew.Enabled = true;
//btnSave.Enabled = false;
}
 

Answers (9)