Auto number problem

Reply

Join Date: Apr 2006
Posts: 62
Reputation: Fenerbahce is an unknown quantity at this point 
Solved Threads: 0
Fenerbahce Fenerbahce is offline Offline
Junior Poster in Training

Auto number problem

 
0
  #1
Nov 18th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 537
Reputation: choudhuryshouvi is an unknown quantity at this point 
Solved Threads: 49
choudhuryshouvi's Avatar
choudhuryshouvi choudhuryshouvi is offline Offline
Posting Pro

Re: Auto number problem

 
0
  #2
Nov 19th, 2007
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
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC