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.
 
Hi John,

Just for testing purposed, pass DS.Tables("Staff") to fill method.
 
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.
 

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

Back
Top