Can someone explain why i get this error message i c# :
Exception thrown: 'System.NullReferenceException' in systemutviklertest.exe Object reference not set to an instance of an object.
with this code
string cs = "Database=db; Data Source=localhost;User=root;Password=pass;";
MySqlConnection con = new MySqlConnection(cs);
con.Open();
string sql = "SELECT * FROM kunde";
MySqlCommand cmd = new MySqlCommand(sql, con);
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
MySqlCommandBuilder cb = new MySqlCommandBuilder(
try
{
DataRow nrad;
nrad = ds.Tables["kunde"].NewRow();
nrad["firmanavn"] = firmanavn.Text;
nrad["adresse"] = adresse.Text;
nrad["postadresse"] = postadresse.Text;
nrad["telefon"] = telefon.Text;
nrad["fax"] = fax.Text;
ds.Tables["kunde"].Rows.Add(nrad);
da.Update(ds, "kunde");
}
catch (Exception s)
{
Console.WriteLine(s.Message);
}
con.Close();
The error shows up at "nrad = ds.Tables["kunde"].NewRow();