Hi, I am doing a window servise application using VB.net. I have faced problems with sql suery, as below:
Dim dt As New DataTable() SQLStr = "SELECT FautyScanTbl.Model, FautyScanTbl.Version, FautyScanTbl.WIP, FautyScanTbl.ScanNo, FautyScanTbl.LotSize, FautyScanTbl.SerialNo, FautyScanTbl.PIC," & _ "SerialNoTbl.SetWeight, SerialNoTbl.AccesWeight, SerialNoTbl.pdmid, ScannedPartNoTbl.ScannedTime " & _ "FROM FautyScanTbl LEFT OUTER JOIN " & _ "ScannedPartNoTbl ON FautyScanTbl.ID = ScannedPartNoTbl.ID LEFT OUTER JOIN" & _ "SerialNoTbl ON FautyScanTbl.ID = SerialNoTbl.ID" dt = AccessDb_Cmd.RetrieveData(SQLStr, Access_Db).Tables(0)
the retrieve command method:
Public Function RetrieveData(ByVal Cmd As String, ByVal mTrans As SQLClass) As DataSet Try Dim ds As New DataSet() OleDbCmd = New SqlCommand(Cmd, mTrans.TransConn, mTrans.Trans) DataAdp = New SqlDataAdapter(OleDbCmd) ds.Clear() DataAdp.Fill(ds) Return ds Catch ex As Exception Throw New Exception(ex.Message) Finally ds.Dispose() OleDbCmd.Dispose() DataAdp.Dispose() End Try End Function
When I debug, I found that an exception occured at line 8 (DataAdp.Fill(ds)), and when I point the pointer to the ds, the ds has nothing. Thus I thinks problem should be appreared in my query, the debug indicator on the "ex" stated that "Incorrect syntax near the keywords ON".
Anyone know what is the problems with my query?