This piece of code is giving an error
The code is giving the error:
An unhandled exception of type 'System.NullReferenceException' occurred in WindowsApplication2.exe
Additional information: Object reference not set to an instance of an object.
Here is the code:
OleDbConnection connToStore = new OleDbConnection( @"Provider=Microsoft.Jet.OLEDB.4.0; User Id=; Password=; Data source= "+db_storage);
connToStore.Open();
string cmdstr = "INSERT INTO trans_table( dataElement1, dataElement2, transformationDetail )" + "VALUES ('"+listBox_for_db1.Items[indexOfItemUnderMouseToDrag].ToString()+"','"+listBox_for_db2.Items[indexOfItemUnderMouseToDrag].ToString()+"','"+textBox_for_transformation.Text+ "')";
this.adapt.InsertCommand.Connection = connToStore;
this.adapt.InsertCommand.CommandText = cmdstr;
this.adapt.InsertCommand.ExecuteNonQuery();
connToStore.Close();
MessageBox.Show("successful");
|