日期:2014-05-19  浏览次数:20517 次

急死了~~`两个表关联,datagrid显示 出错!
Dim   Myconnection   As   OleDbConnection
                Dim   ada   As   OleDbDataAdapter
                Dim   ds   As   DataSet

                Myconnection   =   New   OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA   Source= "   &   AppDomain.CurrentDomain.BaseDirectory   &   "alarmsys.mdb ")
                Myconnection.Open()
                ada   =   New   OleDbDataAdapter
                ds   =   New   DataSet
                ada.SelectCommand   =   New   OleDbCommand
                ada.SelectCommand.Connection   =   Myconnection
                ada.SelectCommand.CommandText   =   "SELECT   ALARM.DATE   FROM   ALARM,town   where   ALARM.NOX   =   town.NOX   AND   ALARM.ZONE   =   town.ZONE "
                ada.SelectCommand.CommandType   =   CommandType.Text
                ada.Fill(ds,   "alarm ")
                dgBJXX.DataSource   =   ds
                dgBJXX.DataBind()

------解决方案--------------------
报什么错!
"SELECT ALARM.DATE FROM ALARM,town where ALARM.NOX = town.NOX AND ALARM.ZONE = town.ZONE "

改为
"SELECT ALARM.DATE AS ALARM FROM ALARM,town where ALARM.NOX = town.NOX AND ALARM.ZONE = town.ZONE "