|
If rs.BOF AND rs.EOF are both true then the rs is either nothing or empty. In which case don't let your code use the rs.
Sounds like the underlying db has just been populated and you are attempting to get records from it before the db has finished updating itself i.e. after data has been sent to it. Are you using Access by any chance? Try putting a wait in your code after the db has been populated.
|
|
|
|
|
|
Yes I am using an Access Db. Could you give me an example of using the wait code for recordsets or after the db has been populated? I was looking on the net and could not find anything! Thanks so much for your help! Looking forward to your response!
|
|
|
|
|
The correct solution to your problem would be to open an asyncronous connection and then when you have written your data to the db wait until the connection has finished executing the SQL command.
Use the ADO const dbRunAsync when opening the connection to get an asyncronous connection. Then write the data to the db, and wait by using a loop such as:
Do While Con.StillExecuting<br />
...<br />
Loop
When the loop exits the db has been updated and you can then retrieve the required data.
HTH
|
|
|
|
|
I am attempting to connect to an Access Database with not much data and am using MDAC version 2.70.7713.4...I have worked around the problem. I noticed that the record I was querying for and then using movefirst to retrieve, was added immediately prior to performing the query for the value associated with the record added.
Before:
'If record did not exist then add record
Dim rs As New ADODB.Recordset
SQL = "TableName"
rs.Open SQL, dbMasterConn, adOpenKeyset, adLockOptimistic, adCmdTable
rs.Addnew
rs!code = varCode
rs.Update
'Following this a rs was filled for generic instances where record did or did not exist for the record just added. Record was only added if it did not exist but the code is needed regardless of whether record did or did not exist
Dim rs As New ADODB.RecordSet
rs.Source = "SELECT code FROM TableName where condition"
rs.CursorType = adOpenForwardOnly
rs.ActiveConnection = dbMaster
rs.Open
rs.MoveFirst <--it stuck here
CodeNeded = rs!code
After changes:
'If record did not exist then
Dim rs As New ADODB.Recordset
rs.ActiveConnection = MasterDb
SQL = "TableName"
rs.Open SQL, , adOpenKeyset, adLockOptimistic, adCmdTable
rs.Addnew
rs!code = varCode
rs.Update
CodeNeeded = varCode
else(if record already exists)
Dim rs As New ADODB.RecordSet
rs.Source = "SELECT code FROM TableName where condition"
rs.CursorType = adOpenForwardOnly
rs.ActiveConnection = dbMaster
rs.Open
rs.MoveFirst <--no longer stuck here and ran.
CodeNeded = rs!code
A very good detailed link that helped with making connections, creating recordsets, reading and adding values to recordsets etc for both DAO and ADO was:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnacc2k/html/acchap2.asp
|
|
|
|
|
Hi!
I've a .exe program writen in ANSI C that returns the real hard drive serial member.
From VB i'm calling it doing like:
MyApp = Shell("Diskid32.exe", 0), but Shell function returns a Variant (Double) representing the program's task ID if successful, otherwise it returns zero, but not the programs output!
Can anyone help me with this?
Thank you for your time
|
|
|
|
|
|
Thank you for answering but what i need is the manufacturer serial number not the volume's!
If i know a way of doing it with VB please tell me!
|
|
|
|
|
|
Well, I found the source for the utility your using. It's at http://www.codeguru.com/system/DiskId32.shtml. The only problem is, your going to have to recode it to be directly usable in VB, possibly as a DLL.
The easier way to do it is to pipe the output from the program to a text file with something like: MyApp = Shell("Diskid32.exe > log.txt", 0) You might have to use another method to get this to launch properly. But, in any case, what your going to have to do is open the log.txt file and parse it up to pull the information out of it.
It's better than writing a custom DLL to do the job...
|
|
|
|
|
Thank you all!
What i did was: I edited the c++ code to write the hard drive serial number to a file, that is imediatilly read and erased from the vb code, its not the best solution but i guess it shall work...
Thank you once more
|
|
|
|
|
Does anyone have or know where I can get hold of a ListView control which can be used in VB6 with the capability of multi-line ColHeading's?
If not I will see about creating my own, in C++ for use in VB6.
|
|
|
|
|
previously, when generating reports, I entered a range of dates by means 2 textboxes. However, for the purposes of validation, i found this an inadequate way (eg it allows entry of days > 31 etc). instead i have started to use an MaskEdBox, i have set the DataFormat to Date, how do i set the format to ##/##/####? does it have similiar properties to that of the textbox? (ie MaskEdBox.Text etc)any help would be greatly appreciated, i am a newbie to this control!Thank you!
|
|
|
|
|
mcm wrote:
how do i set the format to ##/##/####?
MaskEdBox1.Mask = "##/##/####"
You will need to check the values to make sure that the user entered the correct values, I would suggest you write a function:
Private Sub MaskEdBox1_KeyPress(KeyAscii As Integer)
'Do your stuff here...
End Sub
Nick Parker
The only man who never makes a mistake is the man who never does anything. - Theodore Roosevelt
|
|
|
|
|
Why dont' you try a DTPicker control - resembles a Combo, but when you hit the drop-down, it shows a Month in a calendar control. Still possible to directly enter a date, but won't let you enter an invalid one.
To use, right click your toolbox and select components. Scroll down the resulting list, and select "Microsoft Windows Common Controls 2 6.0 SP4", or browse to MSCOMCTL2.ocx. This will add the control to your toolbox, and can be used in the normal way. Help for the control is in MSDN under VBReference->Controls Reference->ActiveX COntrols
(Apologies if the preceeding is teaching my granny to suck eggs!)
|
|
|
|
|
Dim updateSQL As String
updateSQL = "Update Product Set " & _
" Description = '" & txtDesc.text & "', " & _
" Where Code = '" & txtCode.Text & "'"
Set RS = Conn.Execute(updateSQL)
This statement executes fine when i test it in access but here, it returns the above error. I have checked that all the fields are the same as that in the database and the textboxes match aswell. Neither txtcode or txtDesc are bound to any component. What could the problem be? if you need any more information, please let me know, any help would be greatly appreciated!!
|
|
|
|
|
You don't need the comma after the txtDesc.text. So the correct SQL command should work with:
updateSQL = "UPDATE Product SET Description = '" & txtDesc.text & "'" & _<br />
"WHERE Code = '" & txtCode.text & "'"<br />
<br />
Set RS = Conn.Execute(updateSQL)
HTH
|
|
|
|
|
Hi - i have a website in ASP, and was wondering if it's possible to have a status display of my login status for MSN messenger? (u know like the Yahoo! logged in/not logged in script)
Thanks
Paul W
Only the good die young, all the evil seem to live for ever. - Iron Maiden, Only the Good Die Young
modified 18-Jul-18 11:59am.
|
|
|
|
|
I have an app written in VB6 which uses the MSHFlexGrid. I would like to add heading to the columns which have two lines. Is it possible to use a CR in the heading text or am I forced to use two rows?
If as I suspect I have to use two rows, how do I hide the row lines in the heading rows?
|
|
|
|
|
Hi, I want to make such a software in which i want to connect my SQL database situated on a remote server to the software residing in my PC. So is there any other apporoach other then creating the DSN and using it with ADO?
Please tell me to be a professional software developer should i develope command over VB of VC++
Regards
|
|
|
|
|
Think that you may be misunderstanding things here a little. If you specify a DSN in an ADO conneciton string, the conneciton will actually go through the ODBC driver / layer. However, if you specify a connection string of the format:
strConnString = "Provider = SQLOLEDB;Database=<DBNAME>;<br />
Datasource=<SERVERNAME>"
Then the OLEDB provider for SQLServer will be used to connect to the machine specified by <servername> and the database specified by <dbname>. You'll also have ot provide a UID and PWD though.
|
|
|
|
|
Hi all,
Friend asked me the following question, and since I do not know VB at all, i'll try it here.
So, in a Excel macro, he wants to set the active printer as "\\NTS198\\PFK" which is our color printer. But the port used to install the printer differs from user to user, that is, name of the printer in Excel is sometimes "\\NTS198\\PFK auf Ne02" or "\\NTS198\\PFK auf Ne01". and using Application.ActivePrinter() will throw an error if the name of the printer is not correct. So my question is, how do I find the port on which the "\\NTS198\\PFK" printer is on, so that i can use Application.ActivePrinter() without error ?
~RaGE();
|
|
|
|
|
Hello,
I am developing an application in which i use the OfficeXp component to display the values from the database.
Now i face a problem in making Print Preview and Printing the SpreadSheet using Visual basic.
Thanks,
Regards,
maheswaran
|
|
|
|
|
Hi...Sorry to be a pest. Perhaps related to my earlier post, but I'm getting the following message when I preview the dataset in the IDE: ForeignKeyConstraint 'EmployeeComments' requires the child key values (115) to exist in the parent table.
This doesn't make sense. The relationship seems easy enough. The primary key and foreign keys are the same as far as Interger (8), nulls not allowed. Any ideas.
Thanks in advance,
Mike
|
|
|
|
|
Simple. You have two tables (Table1 and Table2). Table2 has records that relate to records in Table1. The only thing holding the relationship is the fact that the two tables share a common field:
Table1: Table2:
recID ID# of record recID ID# of record in table 1
Name Some name Info1 Some information related to table1
Address Some address Info2 Some information related to table1
Both tables share a recID field. But, Table2 can have multiple records with the the same recID from Table1, this is a 1-to-many relationship. One record in Table1 is related to Many records in Table2.
The problem your running into is there is a recID in Table2 that doesn't exist in Table1. It's a record that doesn't have a relationship to any record in Table1.
You can probably code a SELECT statement to find the 'orphaned' records in Table2 for you, but I don't know exactly how to do it.
|
|
|
|