|
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
|
|
|
|
|
Thank You for the fast answer! I solve the problem and now I can save and open the array in binary file format!
|
|
|
|
|
Welcome
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Hi all,
using vb.net, i like to handle changes done by the user in the system control panel.
Example: In case user changes Date / Time settings i like to use the new settings i a running vb.net application.
What I have done is:
Public Sub New()<br />
MyBase.New()<br />
<br />
'This call is required by the Windows Form Designer.<br />
InitializeComponent()<br />
<br />
'Set the SystemEvents class to receive event notification <br />
'when a user preference changes, the palette changes, or <br />
'when display settings change.<br />
AddHandler SystemEvents.UserPreferenceChanging, AddressOf SystemEvents_UserPreferenceChanging<br />
<br />
End Sub<br />
<br />
<br />
Private Sub SystemEvents_UserPreferenceChanging(ByVal sender As Object, ByVal e As UserPreferenceChangingEventArgs)<br />
MessageBox.Show("UserPreferenceChanging: " & e.Category.ToString())<br />
End Sub<br />
So i get a event in case of changes in the system control panel. This works.
Using the new settings from the control panel i can adjust the frontend and/or change the current culture settings.
But how is it now possible to read the current system settings for date and time ??????
Any comments pls.?!
regards,
bauer
|
|
|
|
|
DateTime.Now will give you the value.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
No, this does not help.
What I like to do is:
VB.NET Applications starts and does some output for Date/Time Values using the current culture settings. This works, data format is englisch, german ...... No Problem.
Now the user changes the date/time format in the windows system control panel from english to german for example.
How to handle this change in the running vb.net application? I like to adjust the output of date/time fields to the new settings of the control panel.
regards,
bauer
|
|
|
|
|
Sory. Misread your question. ToSring method for a DateTime object has an overload that takes in CultureInfo. If you pass CurrentThread.CurrentCulture to it, I believe it would work.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Thank you for your answer.
This does not work, because if you change the windows culture (windows control panel) the Thread Culture in the running vb.net program does not change.
|
|
|
|
|
Just make sure you are calling CurrentCulture.ClearCachedData() method everytime before you access current culture. That will give the latest information.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|