我在 Visual Studio 2008 上使用 VB.NET
错误:关键字“and”附近的语法不正确。
代码。
sb.Remove(0, sb.Length())
sb.Append("SELECT tf.*")
sb.Append(" FROM filesTA tf")
sb.Append(" WHERE tf.ChkDate = '" & dateTimePicker.Value.ToString("yyyy-MM-dd") & "'")
Dim SqlLR As String = sb.ToString()
da.SelectCommand.CommandText = SqlLR
da.Fill(ds, "filesTA9")
If ds.Tables("filesTA9").Rows.Count = 0 Then
sb.Remove(0, sb.Length())
sb.Append("INSERT INTO filesTA (EmpNo,ChkDate,LastUpdate) ")
sb.Append("SELECT tft.EmpNo,tft.ChkDate,tft.LastUpdate ")
sb.Append("FROM TA_FillTime tft ")
sb.Append("WHERE Convert(nvarchar(10),tft.ChkDate,126) Between DATEADD(Day , -1, '" & dateTimePicker.Value.ToString("yyyy-MM-dd") & "' and '" & dateTimePicker.Value.ToString("yyyy-MM-dd") & "'")
sb.Append(" Order By tft.ChkDate ")
Dim SqlLR2 As String = sb.ToString()
da.SelectCommand.CommandText = SqlLR2
da.Fill(ds, "filesTA9") => **Error this line: Incorrect syntax near the keyword 'and'.**
'label1.Text = "Insert Done"
ElseIf ds.Tables("filesTA9").Rows.Count > 0 Then
'label1.Text = "Insert New Done"
Else
'label1.Text = "Insert Done..."
End If
谢谢你的时间。:)