below is my code:
myCommand = New SqlCommand("SELECT VisitorID, VisitorName, Skill FROM tblVisitor LEFT JOIN tblSkill ON tblVisitor.SkillID = tblSkill.SkillID", myConnection)
myAdapter = New SqlDataAdapter(myCommand)
myAdapter.Fill(myDataSet, "tblVisitor")
tblView.DataSource = myDataSet.Tables(0)
then it catch an error as Incorrect Syntax near". which it points to myAdapter.Fill(myDataSet, "tblVisitor") not the Select command.
Please help.
It’s a normal behavior that the exception is thrown on
DataAdapter.Filland not on building the SqlCommand. BecauseFillis the first point where ADO.NET will query your database.What comes after “Incorrect syntax near”? Because normally the database will give you a hint where to find the error in SQL-Statement.
Your SQl-Statement seems to be correct if your Model is similar to this test-model:
The result: