"Multiple- Step operation generated errors. check each status value." error in VB6 Application - vb6

when I try to insert a value to recordset in the 'Description' field. it showing a error like
runtime error '-2147217887(80040e21)'
Multiple- Step operation generated errors. check each status value.
sql = "SELECT * FROM vePODetail WHERE vePOID=" & Str(ado_veReceive.Recordset("vePOID")) & " ORDER BY vePODetailID"
rs.ActiveConnection = g_cnnCompany
rs.Open sql
Do While Not rs.EOF
ado_veReceiveDetailWF.Recordset.AddNew
ado_veReceiveDetailWF.Recordset("vePODetailID") = rs("vePODetailID")
ado_veReceiveDetailWF.Recordset("prMasterID") = rs("prMasterID")
ado_veReceiveDetailWF.Recordset("Description") = rs("Description")
ado_veReceiveDetailWF.Recordset("QuantityReceived") = rs("QuantityOrdered") -rs("QuantityReceived")
ado_veReceiveDetailWF.Recordset.Update
rs.MoveNext
Loop
rs.Close
the field in the recordset acccepts only 50 char.
Please tell how to increase the size/length of the field in the recordset.

If the field is 50 chars long, you must change the DB's definition of the field from 50 to whatever you need. You cannot do that through a recordset

Assuming you're using SQL Server, you can change your query using a CAST operation:
sql = "SELECT vePODetailID,prMasterID,CAST(Description as VARCHAR(100)) AS Description, QuantityReceived FROM vePODetail WHERE vePOID=" & Str(ado_veReceive.Recordset("vePOID")) & " ORDER BY vePODetailID"
That should set the length of the Description field in the recordset to 100 characters. You can do this in other db platforms as well, but the syntax may be different for the CAST.

Related

Formatting an individual column in Access "Table/Query" listbox

I have listbox with 1 columns populated with an Oracle based ADODB Recordset using
strsql = "SELECT '£' || expected_cost as ""Cost"""
lstComm.RowSourceType = "Table/Query"
Set lstComm.
Recordset = rs
The query returns £1.58, but the listbox displays #1.58.
If I use
strsql = "trim(TO_CHAR(round(expected_cost,2), 'L9999999999999.99')) as ""Cost"""
The query returns £1.58, but the listbox displays $1.58.
Is there a way to populate the column as UK currency, whilst keeping the RowSourceType as "Table/Query"?
Simple answer: Yes.
The easiest (and best) way to accomplish this is to use a Currency format type. From there you just change the Format field from Currency to £#,##0.00;(£#,##0.00)

Cannot display correct records in unbound form in Access 2013

I have one Table called tblEmployees - ID, First, Last. One unbound form called frmSearch with a textbox named Searchbox and a search button that searches by ID.I have one more unbound form called frmDisplay that displays the search result in it which I would like to edit when necessary. The textbox fields for this form are EID, Fname, Lname.
The problem I am having is when I enter the ID# in the searchbox and click the search button (where I linked both ID fields in the button wizard) it keeps on displaying the second record in my table. This is the code I currently have running
Private Sub Form_Load()
Dim rst As Recordset
Set rst = CurrentDb.OpenRecordset("SELECT * from tblEmployees WHERE ID=ID")
EID.Value = rst!ID
Fname.Value = rst!First
Lname.Value = rst!Last
end sub
When I change the code to read
("SELECT * tblEmployees WHERE ID=" & ID")
I get a syntax error missing operator in query expression ID="
ID must have some value. Then concatenate ID:
"Select * From tblEmployees Where ID = " & ID & ""
The recordset that's currently being opened will include all the records in your table, because for every record the condition ID = ID will always be true. It's purely coincidence that it's displaying the second record from your table. You didn't specify a sort on the recordset query so it could randomly pick up any record as the first one in the results. What you actually need is
Set rst = CurrentDb.OpenRecordset("SELECT * from tblEmployees WHERE ID = " & frmSearch!Searchbox)

Does ADO Recordset need to be closed?

I have an ADO recordset (not ADO.NET) that I populate in every iteration of a loop.
My question is: Do I need to close the recordset at end of every iteration so it gets populated with fresh data in next iteration OR I could just use the unclosed recordset to populate with new data in next iteration. Please look at code sample below.
set rs=Server.CreateObject("ADODB.recordset")
for count = 0 to 3
rs.Open "Select * from Customers where CustomerId = " & count, conn
'do some processing of data in recordset
'rs.Close 'NOT VERY SURE IF I NEED TO DO THIS
next
You cannot open a recordset again :
Error 3705 : Operation is not allowed when the object is open
So given the sample above which requires a different selection of data, you must close the recordset.

VB6 Recordset "Open" taking more time to show result as compared to backend

I am using a query to find data.
Same query taking less time i.e 2 sec to execute from backend.
But in code same query taking more time i.e 30 sec in recordset.open.
Database : Sybase
Thanks
Code Sample :
Dim rsRoute As New ADODB.Recordset
---------------------------------------------
If rsRoute.State = 1 Then rsRoute.Close
Set rsRoute = New ADODB.Recordset
Set rsRoute.ActiveConnection = con
rsRoute.CursorLocation = adUseClient
rsRoute.CursorType = adOpenKeyset
rsRoute.LockType = adLockBatchOptimistic
strCmd = " select * from Table where CoumnVal =1 "
con.Errors.Clear
On Error Resume Next
rsRoute.Open strCmd
There are several types of CursorsType and two different CursorLocation varieties. On the Sybase database (ASE back in the day) the performance differs wildly depending on what you choose. Try both client-side and server-side cursors and see what happens.
If you just need to loop through the result once, select the adOpenForwardOnly cursor type. It usually results in the best performance.
EDIT: Based on the code you posted, try a) not locking anything (e.g LockType), b) using a adOpenForwardOnly cursor, a) the keep the cursor on the server (adUseServer)

How to get sets of Records in VB6?

Hey guys, just want to ask you a simple question that I know you're familiar with... I am using VB6, I just want to get sets of records from my database. What I mean is that I have UserID and with a part of code provided below, it only gets a single set of record. Like for instance, the value of UserID is A12, and so, all sets of records with the UserID of A12 must display in Textboxes respectively with the aid of datPayroll.Recordset.MoveNext.
With datPayroll
.RecordSource = "select * from tblpayroll where empid like '" & UserID & "'"
.Refresh
Me.txtRegularHours.Text = .Recordset.Fields!reghours
End With
-datPayroll : DataControl
-txtRegularHours : Textbox
-UserID : Variable
You probably want to look at MoveFirst, MoveNext, etc. and also EOF
Here is a link or two to get you started:
EOF, BOF
MoveFirst, MoveNext
You need to check that you have some data in your Recordset using EOF, then MoveFirst to move to the first record, and loop through using MoveNext.

Resources