Retrieve POS data

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Dec 2008
Posts: 21
Reputation: sackymatt is an unknown quantity at this point 
Solved Threads: 0
sackymatt sackymatt is offline Offline
Newbie Poster

Re: Retrieve POS data

 
0
  #11
Jul 20th, 2009
Hi Johnly,
Hi vb5prgrmr,

Yah the name of the text box is where iam entering the barcode. And the name of the data control is actually Store i just forgot to change it when i posted the thread,.
This is actually a POS system, u know when a cashier enters a barcode/itemcode and display everything associated to that item,, thats exactly what i want to know how..

i tried the following code though to connect/open my database
<code>
Option Explicit

Private Sub cmdAccept_Click()
Dim cn As New ADODB.Connection
Dim strCNString As String
Dim RS As New ADODB.Recordset
Dim Txt As String

On Error GoTo ErrHandler
'Connect to database
strCNString = "Data Source=Store.mdb"
cn.Provider = "Microsoft Jet 4.0 OLE DB Provider"
cn.ConnectionString = strCNString
cn.Properties("Jet OLEDBatabase Password") = "sakaria"
cn.Open
'Open recordsource
With RS
.Open "Select * from items where barcode='" & txtcode.Text & "' , cn, adOpenDynamic, adLockOptimistic

End With

ExitHere:
Exit Sub

ErrHandler:
MsgBox Err.Number & " " & Err.Description, vbCritical, "Sale ..."
cn.Close
End Sub
</code>

it worked well with my log in form but unfortunately not with the form in discussion.Is there maybe something wrong with the code?

vb5prgrmr, i tried to do wat u instructed me to do but unfortunately it didnt work, when i opened its telling me unrecognized database format.. but any how i checked the data wizard on the net how it works on the folowing link
http://msdn.microsoft.com/en-us/library/aa291437%28VS.71%29.aspx
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 832
Reputation: vb5prgrmr will become famous soon enough vb5prgrmr will become famous soon enough 
Solved Threads: 152
vb5prgrmr vb5prgrmr is offline Offline
Practically a Posting Shark

Re: Retrieve POS data

 
0
  #12
Jul 20th, 2009
Okay, the reason your access database/vb6 creates that error is because VB6 is quite dated and to resolve that problem you would need to save your database to a previous format. Once that is done you should be able to run the wizard but as for converting back to the database format you want to use, I don't think the ADODC will be able to handle then new format (maybe it will if you change its connection string through code but I have never tried, I always use code).


Good Luck
If anyone has helped you solve your problem, please mark your thread as solved.

Thanks
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 21
Reputation: sackymatt is an unknown quantity at this point 
Solved Threads: 0
sackymatt sackymatt is offline Offline
Newbie Poster

Re: Retrieve POS data

 
0
  #13
Jul 20th, 2009
Ok vb5prgrmr will try my best on that.
THANX
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 16
Reputation: oscarresonable is an unknown quantity at this point 
Solved Threads: 1
oscarresonable oscarresonable is offline Offline
Newbie Poster

Re: Retrieve POS data

 
0
  #14
Jul 21st, 2009
if you are using sql or access then here it is.....

set rsItem = nothing
set rsItem = select * from TblItem where Item_No = '"& txtItemNo.text &"'

if rsitem.recordcount <> 0 then
txt1.text = rsitem!fieldname1
txt2.text = rsitem!fieldname2
end if


that's all....
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 21
Reputation: sackymatt is an unknown quantity at this point 
Solved Threads: 0
sackymatt sackymatt is offline Offline
Newbie Poster

Re: Retrieve POS data

 
0
  #15
Jul 21st, 2009
oscarresonable, am using access and does rsItem supposed to be the database name or table name? and wat is the first code that i must place b4 this one..
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 21
Reputation: sackymatt is an unknown quantity at this point 
Solved Threads: 0
sackymatt sackymatt is offline Offline
Newbie Poster

Re: Retrieve POS data

 
0
  #16
Jul 30th, 2009
Hi Johnly, Long time i didnt here from you..still up to assist me?
or any one else out there, still cant go thru' with retrieving of data from the data base..
Further assistance will be appreciated
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 17
Reputation: johnly is an unknown quantity at this point 
Solved Threads: 4
johnly johnly is offline Offline
Newbie Poster

Re: Retrieve POS data

 
0
  #17
Jul 30th, 2009
Hi Sackymatt,

I totally agree with vb5prgmr, that writing code is better.

Ok since you have already tried some code then forget about all that data control and linking the texboxes with the data control and all those stuff.

Lets write some code.

First add a new reference for 'Microsoft ActiveX Data Objects 2.x library', if it is not added.

Now we will use ADODB objects to accees the database and write SQL query to fetch the record.

Try the following code.

  1. Private Sub cmdAccept_Click()
  2. On Error GoTo ErrHandler
  3. Dim strCNString As String
  4.  
  5. strCNString = "Provider=MSDASQL.1;Persist Security Info=False;DBQ="
  6. strCNString = strCNString & App.Path & "\store.mdb;" 'DefaultDir=" & App.Path & ";"
  7. strCNString = strCNString & "Driver={Microsoft Access Driver (*.mdb)};DriverId=281;FIL=MS Access;"
  8. strCNString = strCNString & "MaxBufferSize=2048;password=sakaria;UID=admin;"
  9.  
  10. Dim Con As New ADODB.Connection
  11. Con.Open strCNString
  12.  
  13. Dim RS As New ADODB.Recordset
  14. Dim strSQL As String
  15.  
  16. strSQL = "select * from items where barcode = '" & txtCode.Text & "'"
  17.  
  18. RS.Open strSQL, Con, adOpenForwardOnly, adLockOptimistic
  19. If Not RS.BOF Then 'at least one record found
  20. txtItemName.Text = RS!itemname & vbNullString
  21. txtItemDesciption.Text = RS!itemdescription & vbNullString
  22. txtUnitPrice.Text = Format(Val(RS!unitprice & vbNullString), "0.00")
  23. Else
  24. txtItemName.Text = vbNullString
  25. txtItemDesciption.Text = vbNullString
  26. txtUnitPrice.Text = vbNullString
  27. End If
  28. RS.Close
  29.  
  30. ExitHere:
  31. Exit Sub
  32. ErrHandler:
  33. MsgBox Err.Number & " " & Err.Description, vbCritical, "Sale ..."
  34.  
  35. End Sub

in the above code I am opening a ADODB Connection object using a connection string. I am using MSDASQL provider.
Then opening a recordset by passing an SQL query. I am adding vbNullstring to handle the null values in the database.

Hope this will be a final solution

Regards...
Last edited by johnly; Jul 30th, 2009 at 4:56 pm. Reason: slight cosmetic changes
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 21
Reputation: sackymatt is an unknown quantity at this point 
Solved Threads: 0
sackymatt sackymatt is offline Offline
Newbie Poster

Re: Retrieve POS data

 
0
  #18
Jul 30th, 2009
Jonhly,can i still do this using my msaccess database?
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 17
Reputation: johnly is an unknown quantity at this point 
Solved Threads: 4
johnly johnly is offline Offline
Newbie Poster

Re: Retrieve POS data

 
0
  #19
Jul 30th, 2009
Yes, you can
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 21
Reputation: sackymatt is an unknown quantity at this point 
Solved Threads: 0
sackymatt sackymatt is offline Offline
Newbie Poster

Re: Retrieve POS data

 
0
  #20
Aug 3rd, 2009
Thanx Johnly, the code worked very well,,and thanks to every one that participated in this thread.. my problem has been solved..
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC