Dataset help needed

C

Chris Kettenbach

Hi All,
Quick question. Can I use more than two tables as a source for a dataset? I
am trying to fill a dataadpater but when I include more than two tables, it
bombs out. Example:
________________________________________________________
This works
cmd = New OleDbCommand("SELECT FirstName, LastName " & _
"FROM (Event_Registration INNER JOIN Employees ON " & _
"Event_Registration.EmployeeID = Employees.EmployeeID) " & _
"WHERE EventID=?", cn)

Dim param As OleDbParameter
Dim ds As New DataSet
ds.DataSetName = "Registrations"

For Each param In p
cmd.Parameters.Add(param)
Next

Dim adptr As OleDbDataAdapter = New OleDbDataAdapter(cmd)

adptr.Fill(ds, "Event") This fails

_________________________________________________________________
This fails

cmd = New OleDbCommand("SELECT FirstName, LastName " & _
"FROM (Event_Registration INNER JOIN Employees ON " & _
"Event_Registration.EmployeeID = Employees.EmployeeID) " & _
"INNER JOIN [Names] ON Employees.NameID = Names.NameID WHERE EventID=?", cn)

Dim param As OleDbParameter
Dim ds As New DataSet
ds.DataSetName = "Registrations"

For Each param In p
cmd.Parameters.Add(param)
Next

Dim adptr As OleDbDataAdapter = New OleDbDataAdapter(cmd)

adptr.Fill(ds, "Event") '<~~~ fails here when join has more than two tables

_________________________________________________________________

Any suggestions? Am I doing something wrong? Thanks Everybody!!!

Chris
 
M

Marina

1. You should always include the complete error message - that is the key to
solving any programming issue involving an exception.
2. Any valid query will do, there are no limitations. The problem lies with
your query, something in it isn't structured right. Perhaps if Names is a
keyword, you need to put the brackets around it everywhere you reference it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top