| | |
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:
Solved Threads: 0
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 OLEDB
atabase 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
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 OLEDB
atabase 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
•
•
Join Date: Mar 2009
Posts: 832
Reputation:
Solved Threads: 152
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
Good Luck
If anyone has helped you solve your problem, please mark your thread as solved.
Thanks
Thanks
•
•
Join Date: Nov 2008
Posts: 17
Reputation:
Solved Threads: 4
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.
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...
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)
Private Sub cmdAccept_Click() On Error GoTo ErrHandler Dim strCNString As String strCNString = "Provider=MSDASQL.1;Persist Security Info=False;DBQ=" strCNString = strCNString & App.Path & "\store.mdb;" 'DefaultDir=" & App.Path & ";" strCNString = strCNString & "Driver={Microsoft Access Driver (*.mdb)};DriverId=281;FIL=MS Access;" strCNString = strCNString & "MaxBufferSize=2048;password=sakaria;UID=admin;" Dim Con As New ADODB.Connection Con.Open strCNString Dim RS As New ADODB.Recordset Dim strSQL As String strSQL = "select * from items where barcode = '" & txtCode.Text & "'" RS.Open strSQL, Con, adOpenForwardOnly, adLockOptimistic If Not RS.BOF Then 'at least one record found txtItemName.Text = RS!itemname & vbNullString txtItemDesciption.Text = RS!itemdescription & vbNullString txtUnitPrice.Text = Format(Val(RS!unitprice & vbNullString), "0.00") Else txtItemName.Text = vbNullString txtItemDesciption.Text = vbNullString txtUnitPrice.Text = vbNullString End If RS.Close ExitHere: Exit Sub ErrHandler: MsgBox Err.Number & " " & Err.Description, vbCritical, "Sale ..." 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
![]() |
Similar Threads
- How to retrieve binary data from string (Java)
- How to make query to retrieve first,last,next,Preivius data from databse (Oracle)
- SELECT and RETRIEVE MYsql Data... (PHP)
- Retrieve data from SQLDataSource (ASP.NET)
- How do I retrieve data from my Crashed Hard Disk? (Windows NT / 2000 / XP)
- How can i retrieve data after i logod on..... (ASP.NET)
- Retrieve the data from the url api (RSS, Web Services and SOAP)
- Login and retrieve user data from database (ASP.NET)
- please help! this is urgent> how to retrieve data to my tabpage without using data fo (C#)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Data report Printing Problem
- Next Thread: Passing argument in a property explanation
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





