SQL Select statement has an error

levyuk

Well-known member
Joined
Jun 7, 2004
Messages
313
Location
Wales, UK
Programming Experience
3-5
Anyone see anything wrong with this.

VB.NET:
[size=2][color=#0000ff]Try

[/color][/size][size=2][/size][size=2][color=#0000ff]Dim[/color][/size][size=2] table [/size][size=2][color=#0000ff]As[/color][/size][size=2] DataTable

table = [/size][size=2][color=#0000ff]New[/color][/size][size=2] DataTable

OleDbConnection1.Open()

[/size][size=2][color=#0000ff]Me[/color][/size][size=2].OleDbDataAdapter1.SelectCommand.CommandText = "SELECT S.EnrolmentNumber, S.Forename, S.Surname, S.TelephoneNumber, C.CompanyName, C.ContactName, C.ContactNumber, S.Location, S.Jobtype FROM (Student S INNER JOIN Company C ON " & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].ComboBoxStudentJobType.SelectedItem & " = C.JobType AND " & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].ComboBoxStudentLocation.SelectedItem & " = C.Location) WHERE (S.Placed = No)"

[/size][size=2][color=#0000ff]Me[/color][/size][size=2].OleDbDataAdapter1.Fill(table)

[/size][size=2][color=#0000ff]Me[/color][/size][size=2].OleDbConnection1.Close()

[/size][size=2][color=#0000ff]Me[/color][/size][size=2].DataGrid1.DataSource = table

[/size][size=2][color=#0000ff]Catch[/color][/size][size=2] ex [/size][size=2][color=#0000ff]As[/color][/size][size=2] Exception

MessageBox.Show(ex.Message)

[/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]Try

[/color][/size]

Sorry about the long select going off the page.

I get this error message "Syntax error (missing operator) in query expression 'Java Developer = C.JobType'"
 

ritesh_jain1982

Well-known member
Joined
Jan 10, 2005
Messages
53
Programming Experience
1-3
Hi,
try with replacing

Me.ComboBoxStudentJobType.SelectedItem with

Me.ComboBoxStudentJobType.SelectedValue or Me.ComboBoxStudentJobType.text as per ur requirement

(do same for Location Combo,,,,,,,,,,,,)

Hope this will work...................

Regards,
Ritesh
 
Top Bottom