No data via code

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

When I create a dataadpater by dragging the staff table over a form and
modifying the sql then I can use preview data to show the data fine. If, on
the other hand, I try to get the data using the below code then the number
of records returned is zero. What is the problem?

Thanks

Regards

st2 = "SELECT `unique`, name " & _
"FROM staff " & _
"WHERE (inactive = 0) AND (`unique` > 1 OR `unique` = - 2) ORDER BY name"
Debug.Write(st2)

OdbcCmdStaff.CommandText = st2
OdbcCmdStaff.Connection = m_objConnection
OdbcDAStaff.SelectCommand = OdbcCmdStaff

DS.Tables("Staff").Clear()
OdbcDAStaff.Fill(DS)

Debug.Write("Records: " & DS.Tables("Staff").Rows.Count.ToString) ' <==
rows.count come out zero.
 
Second, related issue. How can I get the values of the field 'unique' into a
combo box display list? I think I need to assign something to the
displaymember property of the combo box but not sure what.

Thanks

Regards
 
Hi John,

Assign string 'unique' to DisplayMember, DS.Tables("Staff") as datasource.
BTW it is a bad practice to use non chars/numerics for table/column names.
 
Back
Top