How to select a value in the database

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2009
Posts: 4
Reputation: jetjash is an unknown quantity at this point 
Solved Threads: 0
jetjash jetjash is offline Offline
Newbie Poster

How to select a value in the database

 
0
  #1
Nov 3rd, 2009
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

  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
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 94
Reputation: yorro has a little shameless behaviour in the past 
Solved Threads: 6
yorro yorro is offline Offline
Junior Poster in Training
 
0
  #2
Nov 3rd, 2009
  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
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 320
Reputation: TomW is on a distinguished road 
Solved Threads: 44
TomW TomW is offline Offline
Posting Whiz
 
0
  #3
Nov 3rd, 2009
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".
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 1
Reputation: JAM1011 is an unknown quantity at this point 
Solved Threads: 0
JAM1011 JAM1011 is offline Offline
Newbie Poster

Same Problem

 
0
  #4
Nov 3rd, 2009
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.


  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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,344
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 602
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast
 
0
  #5
Nov 3rd, 2009
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:
  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.
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Reply

Tags
vb.net

Message:


Thread Tools Search this Thread



Tag cloud for vb.net
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC