Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 7th, 2003, 06:29 PM
anish001 anish001 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 6 anish001 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question simple database question

I have a database called eastwest.mdb . one of the table in database is named "tblpart" and it contains following fields.

recrdno (autonumber)
partno(text)
cavities(text)
hits(text)

I am trying to use following code to get data out of database if user enters partno and cavities and it's not working for me. can somebody point to me where's the mistake? thanks in advance

Dim response As Integer
Dim con_3 As New ADODB.Connection
Dim rs As New ADODB.Recordset

con_3.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\eastwest.mdb;Persist Security Info = false"

rs.Open "Select * from tblpart where [partno] =' " & Trim(TxtPartNo.Text) & "' and [cavities] =' " & Trim(Text3.Text) & " ' ", con_3, adOpenKeyset, adCmdTable

If rs.RecordCount > 0 Then
response = MsgBox("Record already exists in database. Do you want to update it?", vbYesNo + vbQuestion, "Save Part no")
If response = vbYes Then
con_3.BeginTrans
If Trim(Text1.Text) <> "" Then
rs!costperlb = Text1.Text
Else
rs!costperlb = "1.00"
End If
rs!wghtper100 = Text2.Text
rs!hits = Text4.Text
rs!inspectionpcs = Text5.Text
rs.Update
con_3.CommitTrans
rs.Close
con_3.Close
Exit Sub
Else
rs.Close
con_3.Close
Exit Sub
End If
end if

Everty time I do that i get no data in my recordset. but if I simply use following code
rs.Open "Select * from [tblpart]", con_3,adOpenKeyset, adCmdTable
I get all the records in database in my recordset

I did check all fields and their type and everything is correct.

can anybody help?

Thanks Again

Reply With Quote
  #2  
Old October 7th, 2003, 11:43 PM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,840 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 36 m 16 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
try building the query to a string, printing the string to a message box so that you can see what it is, or use the debugger...

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > simple database question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT