943,944 Members | Top Members by Rank

Ad:
Nov 18th, 2007
0

Auto number problem

Expand Post »
Query = "select * from table2 where number='" + Text5.Text + "'"
Rs.Open (Query), Conn, adOpenStatic, adLockReadOnly

Hi,
If "number" is defined as Auto number in Access database, second line generates an error. If "number" is not defined as Auto number then, no problem. What can i do?
Thanks
Similar Threads
Reputation Points: 15
Solved Threads: 0
Junior Poster in Training
Fenerbahce is offline Offline
62 posts
since Apr 2006
Nov 19th, 2007
0

Re: Auto number problem

try the following code :-

take two labels(label1 and label2) and a textbox(Text1)
here the database ->"aa.mdb"
table ->"aa"
fields ->"id" (long,autonumber) ; "name" (text)

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim conn As New ADODB.Connection
  2. Dim rs As New ADODB.Recordset
  3. Dim str As String
  4.  
  5. str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\aa.mdb;Persist Security Info=False"
  6. conn.ConnectionString = str
  7. conn.Open
  8.  
  9. str = "select * from aa where id = " & Val(Text1.Text)
  10. rs.Open str, conn, adOpenStatic, adLockReadOnly
  11. If rs.RecordCount > 0 Then
  12. Label1.Caption = rs!id
  13. Label2.Caption = rs!Name
  14. Else
  15. MsgBox "No record found."
  16. End If
  17. Text1.Text = ""
  18. Text1.SetFocus
Reputation Points: 30
Solved Threads: 49
Posting Pro
choudhuryshouvi is offline Offline
553 posts
since May 2007

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 Visual Basic 4 / 5 / 6 Forum Timeline: change color of border
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: need help for project





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


Follow us on Twitter


© 2011 DaniWeb® LLC