943,877 Members | Top Members by Rank

Ad:
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Jul 20th, 2009
0

Re: Retrieve POS data

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
Reputation Points: 10
Solved Threads: 0
Light Poster
sackymatt is offline Offline
29 posts
since Dec 2008
Jul 20th, 2009
0

Re: Retrieve POS data

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
Reputation Points: 156
Solved Threads: 296
Posting Virtuoso
vb5prgrmr is offline Offline
1,670 posts
since Mar 2009
Jul 20th, 2009
0

Re: Retrieve POS data

Ok vb5prgrmr will try my best on that.
THANX
Reputation Points: 10
Solved Threads: 0
Light Poster
sackymatt is offline Offline
29 posts
since Dec 2008
Jul 21st, 2009
0

Re: Retrieve POS data

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....
Reputation Points: 10
Solved Threads: 1
Newbie Poster
oscarresonable is offline Offline
16 posts
since Sep 2008
Jul 21st, 2009
0

Re: Retrieve POS data

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..
Reputation Points: 10
Solved Threads: 0
Light Poster
sackymatt is offline Offline
29 posts
since Dec 2008
Jul 30th, 2009
0

Re: Retrieve POS data

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
Reputation Points: 10
Solved Threads: 0
Light Poster
sackymatt is offline Offline
29 posts
since Dec 2008
Jul 30th, 2009
0

Re: Retrieve POS data

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.

vb Syntax (Toggle Plain Text)
  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
Reputation Points: 10
Solved Threads: 4
Newbie Poster
johnly is offline Offline
17 posts
since Nov 2008
Jul 30th, 2009
0

Re: Retrieve POS data

Jonhly,can i still do this using my msaccess database?
Reputation Points: 10
Solved Threads: 0
Light Poster
sackymatt is offline Offline
29 posts
since Dec 2008
Jul 30th, 2009
0

Re: Retrieve POS data

Yes, you can
Reputation Points: 10
Solved Threads: 4
Newbie Poster
johnly is offline Offline
17 posts
since Nov 2008
Aug 3rd, 2009
0

Re: Retrieve POS data

Thanx Johnly, the code worked very well,,and thanks to every one that participated in this thread.. my problem has been solved..
Reputation Points: 10
Solved Threads: 0
Light Poster
sackymatt is offline Offline
29 posts
since Dec 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

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: Data report Printing Problem
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Passing argument in a property explanation





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


Follow us on Twitter


© 2011 DaniWeb® LLC