No tables returned from a SQL query. How could that happen?
Im having an issue with the开发者_运维问答 next code:
try
{
OleDbConnection Conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Database.accdb;Jet OLEDB:Database Password=LuzDary;");
OleDbDataAdapter Data = new OleDbDataAdapter("SELECT * FROM Articulos", Conn);
DataSet DSet = new DataSet();
Conn.Open();
Data.Fill(DSet);
Conn.Close();
_Articulos = DSet.Tables["Articulos"];
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
The try/catch is there because my VStudio 2010 installation isnt quite capable of detecting COM Exceptions somehow (Had the same issue creating the database with ADOX, the exception was uncaught, the code kept on running responsively somehow, but the DB was never written to the disk).
The DB already has the "Articulos" table, and i manually inserted some records there, but if i foreach the DataSet, i only get a Table named "Table". This is getting frustrating now :(
DSet.Tables[0].Rows is what you want.
This is what I mean.
_Articulos = DSet.Tables[0];
With that, _Articulos.Rows should be populated with the records in your database.
精彩评论