944,052 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 1776
  • VB.NET RSS
Nov 3rd, 2009
0

How to select a value in the database

Expand Post »
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

VB.NET Syntax (Toggle Plain Text)
  1. cmd.CommandText = "select distinct Name from T_Person where personid = '" & txtno & "'"
  2. Set rs = cmd.Execute
  3. While Not rs.EOF
  4. If Not IsNull(rs("Name")) Then
  5. txtName.Text = rs("Name")
  6. rs.MoveNext
  7. End If
  8. Wend

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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jetjash is offline Offline
4 posts
since Jun 2009
Nov 3rd, 2009
0
Re: How to select a value in the database
vb Syntax (Toggle Plain Text)
  1. Dim myDA As New OleDbDataAdapter
  2.  
  3. myCmd.CommandText = "select distinct Name from T_Person where personid = '" & txtno & "'"
  4. myDA.SelectCommand = myCmd
  5. myDR = myCmd.ExecuteReader()
  6. While (myDR.Read())
  7. myDR("Name"))
  8. End While
Reputation Points: 8
Solved Threads: 7
Junior Poster
yorro is offline Offline
119 posts
since Aug 2009
Nov 3rd, 2009
0
Re: How to select a value in the database
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".
Reputation Points: 84
Solved Threads: 48
Posting Whiz
TomW is offline Offline
342 posts
since Sep 2009
Nov 3rd, 2009
0

Same Problem

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.


VB.NET Syntax (Toggle Plain Text)
  1. sql = "SELECT DISTINCT Model,Make,Problem,HP FROM Makes"


can anyone point me in the right direction.

thanks
james
Last edited by JAM1011; Nov 3rd, 2009 at 8:21 pm.
Reputation Points: 10
Solved Threads: 0
Light Poster
JAM1011 is offline Offline
29 posts
since Nov 2009
Nov 3rd, 2009
0
Re: How to select a value in the database
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:
sql Syntax (Toggle Plain Text)
  1. SELECT Model, Make, Problem, HP
  2. FROM Makers
  3. GROUP BY Model, Make, Problem, HP
  4. ORDER BY Model, Make, Problem, HP --This is an optional ordering line

It should be similar for access.
Last edited by sknake; Nov 3rd, 2009 at 9:13 pm.
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Need to convert from string to integer
Next Thread in VB.NET Forum Timeline: Loading user input into parralell arrays, Please help!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC