[英]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). 进行尝试/捕获是因为我的VStudio 2010安装程序不能够以某种方式检测到COM异常(使用ADOX创建数据库时遇到了同样的问题,未捕获到异常,代码仍以某种方式保持响应性运行,但是从未写入DB磁盘)。
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". 该数据库已经有“ Articulos”表,并且我在其中手动插入了一些记录,但是如果我获取数据集,则只能得到一个名为“ Table”的表。 This is getting frustrating now :( 现在,这令人沮丧:(
DSet.Tables[0].Rows is what you want. DSet.Tables [0] .Rows是您想要的。
This is what I mean. 这就是我的意思。
_Articulos = DSet.Tables[0];
With that, _Articulos.Rows should be populated with the records in your database. 这样,_Articulos.Rows应该用数据库中的记录填充。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.