Using VB.NET

I am using Combobox, when i select the value in combobox, the date value should display in datetimepicker where date = combobox id

vb6 code

cmd.CommandText = "select distinct Name from T_Person where personid = '" & txtno & "'"
Set rs = cmd.Execute
While Not rs.EOF
   If Not IsNull(rs("Name")) Then
txtName.Text = rs("Name")
    End If

txtno - combobox, txtname = datetimepicker1

The above code is working in vb6, But am new to vb.net

How to modify my code in vb.net

Need vb.net code help

8 Years
Discussion Span
Last Post by sknake
Dim myDA As New OleDbDataAdapter
            myCmd.CommandText = "select distinct Name from T_Person where personid = '" & txtno & "'"
            myDA.SelectCommand = myCmd
            myDR = myCmd.ExecuteReader()
            While (myDR.Read())
            End While

I dont understand the need for a loop to assign control values when only a single value can be displayed in the textbox and datepicker at a time. Also Im a bit confused by the naming conventions, a prefix for txt for a datepicker and your saying your looking for a date but the select statement shows your querying a field named "Name".


I have the same problem I am trying to read distinct values from an Access table but i get a syntax error. heres my code . The Code works fine until I put in the distinct key word.

sql = "SELECT DISTINCT Model,Make,Problem,HP FROM Makes"

can anyone point me in the right direction.


Edited by JAM1011: n/a


Your SQL syntax is invalid. Typically you use Distinct() on a single column. I'm not sure if this is the exact syntax with Access but this is how it would work in MSSQL:

Select Model, Make, Problem, HP
From Makers
Group By Model, Make, Problem, HP
Order By Model, Make, Problem, HP --This is an optional ordering line

It should be similar for access.

Edited by sknake: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.