|
Thanks again. I too found lots of usless post on the web for RecordSet.Eof. The example you posted depends on VB correctly setting the .Eof property when that event occurs, which as far as I can determine, it does not.
|
|
|
|
|
Yes, it does. I tried it with a small query and had no issues. VB doesn't set that value, the internals of the ADODB object does.
|
|
|
|
|
Yes, I know that the AdoDb works as I said. The problem is with AdoDc.
|
|
|
|
|
The answer doesn't change. That property value is only set by the internals of the object, not by VB.
|
|
|
|
|
I am trying to remember something weird about the .BOF and .EOF properties from certain data access controls from my Delphi Days. It went something along the lines that if you set .BOF to true it actually 'points' to an imaginary record one before the physical BOF. So I am wondering if there might be something similar going on in your case. i.e. Is there just one record returned and .EOF is pointing past that record.
I hope that that makes some sort of sense. Trying to explain it to anyone always confused me in Delphi and it appears not to have got any better.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
You have VB.NET Express and you're using the old ADO Data Control?? Why?? The ADO.NET methods are faster and more flexible.
No, this isn't a bug in VB. How many records were returned in the query?
|
|
|
|
|
Thanks for your reply. Using ADO.NET is another matter. The number of records returned depends on the number of records in the database at the time. I know how to "get around" this problem. However, I am searching for an answer to how to get the ADODC control to function properly using the .RecordSet.Eof property. BTW, the ADODB object functions correctly.
|
|
|
|
|
Les Singletary wrote: Using ADO.NET is another matter.
That doesn't answer the question. Using ADO.NET instead of deprecated, obsolete objects, would most assuredly solve your problem, as well as prevent others, such a binding controls to your data. You cannot bind any .NET control or class to the data held in the old ADOxx objects. This severely limits your ability to do data manipulation while using those objects.
|
|
|
|
|
Thanks again for your reply. However, your last reply opens up a whole "can of worms" that I prefer not to get into with this particular problem. I would like to use ADODC if it can be made to work. I will try to post the complete zipped "solution" file later.
|
|
|
|
|
Don't bother to post the project. Noone will download it and execute untrusted code.
|
|
|
|
|
Here is the code for the entire program demostrating the problem. I don't seem to be able to attach a zipped file. You will need to create a form with three controls: Button1, Button2, and Adodc1. Name the form "frmAdoDc". You will need a simple MS Access DB named "Stu" with a table named "Student". The table contains 2 columns: "Id" and "Name". Put the database in the same folder where you store the code below. I hope some one can find how to make this code work. Thanks!
---------------------------------------------------------
Imports ADODB
Public Class frmAdoDc
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim iX As Integer
With Adodc1.Recordset
.MoveFirst()
Do While Adodc1.EOF = False And iX < 10
iX = iX + 1 'needed because of problem
Debug.Print(.Fields("Name").Value)
.MoveNext()
Loop
End With
End Sub
Private Sub frmAdoDc_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim sDir As String = "AdoDc_Example" 'path of root folder for solution
Dim sDb As String = "Stu.Mdb" 'name of database
Dim sFid As String 'path & name of database
Dim iPos As Integer
'---build path where DB is regardless of where this test is stored
sFid = My.Application.Info.DirectoryPath
iPos = sFid.IndexOf(sDir)
sFid = sFid.Substring(0, iPos + sDir.Length + 1) & sDb
With Adodc1
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & sFid & ";"
.RecordSource = "Student"
.Refresh()
End With
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim iX As Integer
Dim db As New ADODB.Connection
Dim rs As New ADODB.Recordset
db.Open("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\VbNet_Test\AdoBasics\Stu2.mdb;")
rs.Open("Select * From Student", db, CursorTypeEnum.adOpenDynamic)
With rs
.MoveFirst()
Do While iX < 10 And .EOF = False
Debug.Print(.Fields("Name").Value)
iX = iX + 1
.MoveNext()
Loop
End With
rs.Close()
db.Close()
End Sub
End Class
|
|
|
|
|
In the code that I posted earlier, Button2 works (AdoDb) whereas Button1 does not (AdoDc) yet the code for both is essentially the same. If I understand Dave Kreskowiak correctly, the problem is in AdoDc object and not in VB. I find this interesting for an OOL. One would think that both objects (adodc & abodb) would take advantage of the same underlying objects and classes for the same methods (e.g. MoveNext) since it represents the same functionality. In any event, it appears that the bug in AdoDc unless someone can demonstrate otherwise.
|
|
|
|
|
HEllo,
I depretly need someones help,
i am using vb.net and have nearly finished a program all i need to do is basically clear data in a txt document after reading it e.g hello.txt
i am using
Dim objReader As New System.IO.StreamReader(FILE_NAME)
where i have dimed the FILE_NAME as string ("hello.txt")
however i then added
Dim objwriter As New System.IO.Streamwriter(FILE_NAME)
and tried
objwriter.writeline("")
which then came up with an error message saying file currently in use. Is there no way that you can read the file and then write data into i?????
If anybody can help me that would be very good
Thanks
Dan
|
|
|
|
|
AFAIK you can't edit a file. You will need to recreate it.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
you have to close the reader before opening the writer.
objReader.Close()
|
|
|
|
|
Hi,
I am hoping that someone will be able to tell me how to do this.
I have a form where i am using file handling. What i want to do in vb.net is look at the code in hello.txt document and then delete the document afterwards. If anyone then types anything then the program is like WTF!!!
If i type in a special password i want the master.txt document to copy and paste but rename the document to hello so that people can retype.
I have got up to the stage where i can read docs, however i don't know how to copy and paste and rename .txt documents on the click of a button.
Please help
Many thanks
Dan
|
|
|
|
|
Dig in to System.IO.File class. It provides a lot of static methods that might help you.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Hi,
I have spent a lot of time to find the way how to create application for time reservation which would look similar to outlook calendar (week or day view).The purpose of the program is to manage appointment to specialists in SPA center.
I can figure out the code for retrieving all the necesary data from database and the code to write the new data, but what i can't is to find then right control (-s) to use for visual illustration of the existing appointments.
So, as I see it, there shoud be two dimnesional table (or something like that) on one axis there should be "specialists" but on other - "timeline", and when I click or drag over the control, system opens new appointment form, where fields for "Time", "Specialist" and "Duration" is allready filled depending on the i clicked/draged over.
Does anyone can suggest me the conrol(-s) that i can use for this purpose? or maybe a sourcecode of something similar is available?
PS>I have a printscreen of similar system, but i couldn't find the way to attach that. So if necessary, I can send it by e-mail or attach it, if somebody tell me how to do that.
Thx in advance.M.
|
|
|
|
|
Check out Janusys's schedule control.
you can find them at: www.janusys.com[^]
Tosch
|
|
|
|
|
I really wanna learn more.
|
|
|
|
|
Hello,
I have 2 datagridviews, DGV1 and DGV2.
I need to make "dynamic interaction" between them, what I mean is the following:
when I am clicking on specific row in DGV1 I need to highlight correspondant row in DGV2. Until here everything works fine.
But in addition, I need the vice-versa:when I am clicking on specific row in DGV2 I need to highlight correspondant row in DGV1.
I am using DGV1_CellEnter and DGV2_CellEnter events
The problem is that I got error that each one call to the other (loop).
I can solve the problem by inserting flag but I would like to know if there is a better and elegant way.
Thank you
Shay Noy
|
|
|
|
|
Short answer, check to see whether the selection of the grid you're working with matches the other selection before changing it. That way, only one update will occurr.
|
|
|
|
|
Can you please be more explicit. Thank you
Shay Noy
|
|
|
|
|
Hi,
I'm currently working on a program where I have very big Integer array - with 81000000 elements.
I want to keep this array and the information within for future work, is there a way to save that
big array in file, and then to restore the array from that file?
Thank you in advance!
|
|
|
|
|
You can do that using serialization. There are classes available in .Net to serialize an object and save it to files. You can use them.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|