Difference between DataTable.Load() and DataTable = dataSet.Tables[];
- by subbu
Hi All ,
I have a doubt i use the following piece of code get data from a SQLlite data base and Load it into a data table
"SQLiteConnection cnn = new SQLiteConnection("Data Source=" + path);
cnn.Open();
SQLiteCommand mycommand = new SQLiteCommand(cnn);
string sql = "select Company,Phone,Email,Address,City,State,Zip,Country,Fax,Web from RecordsTable";
mycommand.CommandText = sql;
SQLiteDataReader reader = mycommand.ExecuteReader();
dt.Load(reader);
reader.Close();
cnn.Close();"
In some cases when I try to load it Gives me "Failed to enable constraints exception"
But when I tried this below given piece of code for same table and same set of records it worked
"SQLiteConnection ObjConnection = new SQLiteConnection("Data Source=" + path);
SQLiteCommand ObjCommand = new SQLiteCommand("select Company,Phone,Email,Address,City,State,Zip,Country,Fax,Web from RecordsTable", ObjConnection);
ObjCommand.CommandType = CommandType.Text;
SQLiteDataAdapter ObjDataAdapter = new SQLiteDataAdapter(ObjCommand);
DataSet dataSet = new DataSet();
ObjDataAdapter.Fill(dataSet, "RecordsTable");
dt = dataSet.Tables["RecordsTable"]; "
Can any one tell me what is the difference between two