|
I know. I just need to know what I am doing wrong with the dataGrid. I commented those lnes out to see if any of the columns would be able to be found.
|
|
|
|
|
OK. Again, on what line does the error occur??
|
|
|
|
|
Hello
I have posted this few days ago, I want to random records form MS access database and according to Christian Graus i have tried this it's working so so but i am still not happy i am still trying it but i dont know what to do now
this was before Christian's rep.
First code
Try<br />
<br />
Me.conTest.ConnectionString = _<br />
"Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source= MyTest.mdb"<br />
Catch eConnection As System.Exception<br />
MessageBox.Show(eConnection.Message)<br />
End Try<br />
<br />
'if array size is smaller then increase as per entry<br />
ArraySize = Count<br />
Dim IntegerArray(ArraySize) As Integer<br />
'sort integers<br />
Call SortArray(ArraySize, IntegerArray)<br />
Try<br />
odaTest.Fill(dsTest)<br />
'lblNo.Text = Me.BindingContext(dsTest.MyTest).Position<br />
Catch eLoad As System.Exception<br />
MessageBox.Show(eLoad.Message)<br />
End Try<br />
Call dsContacts_PositionChanged()<br />
End If<br />
<br />
this is for array <br />
<br />
Private Sub SortArray(ByVal N As Integer, ByVal SortedArray() As Integer)<br />
'increase the array size according to number of entry <br />
For I As Integer = 0 To N<br />
SortedArray(I) = I<br />
Next I<br />
End Sub
============
and this is after rep.
it's workind ok but i am sure i am doing something wrong but what ?
this is the new code
Try<br />
<br />
Me.conTest.ConnectionString = _<br />
"Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source= MyTest.mdb"<br />
Catch eConnection As System.Exception<br />
MessageBox.Show(eConnection.Message)<br />
End Try<br />
Me.conTest.Open()<br />
Dim MyData As New OleDb.OleDbCommand("SELECT *FROM MyTest ORDER BY ID ", conTest)<br />
Dim DR As Data.OleDb.OleDbDataReader = MyData.ExecuteReader<br />
Do While DR.Read = True<br />
ArraySize += 1<br />
Loop<br />
DR.Close()<br />
<br />
'if array size is smaller then increase as per entry<br />
Dim IntegerArray(ArraySize) As Integer<br />
'sort integers<br />
Call SortArray(ArraySize, IntegerArray)<br />
ReDim Asked(ArraySize)<br />
Call dsContacts_PositionChanged()<br />
<br />
Private Sub NavNext()<br />
If AskedQ >= ArraySize Then<br />
MessageBox.Show("Finish want to play again..?", "Finish", MessageBoxButtons.OK)<br />
For I As Integer = 0 To ArraySize<br />
Asked(I) = False<br />
AskedQ = 0<br />
Next<br />
Exit Sub<br />
Else<br />
Try<br />
Do<br />
odaTest.Fill(dsTest)<br />
R = CInt(Rnd() * ArraySize)<br />
'[Go to the next entry]<br />
Me.BindingContext(dsTest, "MyTest").Position = R<br />
Loop Until Asked(R) = False<br />
AskedQ += 1<br />
Asked(R) = True<br />
Catch eLoad As System.Exception<br />
MessageBox.Show(eLoad.Message)<br />
End Try<br />
'[See custom procedures]<br />
Me.dsContacts_PositionChanged()<br />
End If<br />
End Sub
waiting for your kind rep.
thanks you
|
|
|
|
|
bapu2889 wrote: Dim MyData As New OleDb.OleDbCommand("SELECT *FROM MyTest ORDER BY ID ", conTest)
Dim DR As Data.OleDb.OleDbDataReader = MyData.ExecuteReader
Do While DR.Read = True
ArraySize += 1
Loop
This is messy. If you need a count of elements, do select count(*) from mytest to get it in one go. This seems to me to be assuming that the Id's have no gaps in them, can you guarentee that ?
I'm not following how the rest works, but I *think* you're doing what I'd suggest in this instance ( keep a list of all the question Ids, then remove from that list at random to make sure no question gets asked twice )
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hello sir
first of all thank you very much for your super fast rep.
i am trying to get it to it but still i am in dark
you mean
Count = Me.BindingContext(dsTest, "MyTest").Count
some thing like this ?
and i can guarentee you that there is no gape in ID's
sir i am doing this since last one week so i think i am thinking too much and i am not seeing the thing which is in front of me
but it's nice fun
one day i will get there
waiting for your kind rep.
thanks again
|
|
|
|
|
OK, if your IDs are from 0-200, for example, then you need to build a list from 0-200
Then you get a random number between 0 and 200, pull out the number at that location, and get the record with that Id and show it. The next time, the number is between 0 and 199, because there's one less item in the list. You do this, because it means you're pulling at random, but you can never end up with the same record twice.
The other way to do this is to do a random shuffle on your list, you would do that by doing a sort method that returns a random result. Then you can work on the list in sequence.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hello sir
good morning
this is want i have done last night but still it's getting same questions again and again
but i will try your next command today but i dont know that i am going in to right direction
Private Sub Display()<br />
' Open the database.<br />
Dim conn As OleDbConnection = GetDbConnection()<br />
<br />
' See how many records there are.<br />
Dim query As String = "SELECT COUNT(*) FROM MyTest"<br />
Dim cmd As New OleDbCommand(query, conn)<br />
Dim num_records As Integer = cmd.ExecuteScalar()<br />
If txtNum.Text > num_records Then<br />
MsgBox("Hello there is only " & num_records & " records in database" & vbCrLf & _<br />
"So please enter " & num_records & " or less then " & num_records, MsgBoxStyle.Exclamation)<br />
Exit Sub<br />
End If<br />
' Make an array to hold the selected indexes.<br />
Dim num_random As Integer = num_records<br />
Dim Asked(num_random) As Boolean<br />
Dim indexes(num_random - 1) As Integer<br />
Dim sorted_indexes As New SortedList(num_random - 1)<br />
' Generate the indexes.<br />
Dim rand As New Random<br />
Dim I As Integer<br />
For I = 0 To num_random - 1<br />
' Generate the i-th index.<br />
Dim new_value As Integer = rand.Next(0, num_records - I)<br />
<br />
' For each previously generated index <=<br />
' than this one, increment this one.<br />
For j As Integer = 0 To I - 1<br />
If sorted_indexes.GetByIndex(j) <= new_value Then<br />
new_value += 1<br />
End If<br />
Next j<br />
<br />
' Save tjhe new value.<br />
indexes(I) = new_value<br />
sorted_indexes.Add(new_value, new_value)<br />
Next I<br />
query = "SELECT * FROM MyTest " & "WHERE Index=?"<br />
cmd = New OleDbCommand(query, conn)<br />
Dim i2 As Integer<br />
' Fetch record i.<br />
Dim index As Integer = indexes(i2)<br />
cmd.Parameters.Clear()<br />
cmd.Parameters.Add(New OleDbParameter("Index", index))<br />
Dim reader As OleDbDataReader = cmd.ExecuteReader(CommandBehavior.SingleRow)<br />
reader.Read()<br />
lblA.Text = reader.Item(i2).ToString<br />
' Close the connection.<br />
conn.Close()<br />
conn.Dispose()<br />
End Sub
thank you sir for your time
have a nice day
|
|
|
|
|
We run RunAsp Professional with XP to run a prgram that maps a network drive. It will also hide the mapped drive so noone can go to my computer and get to the drive.
My question, runAsp Professional does not work with Vista. Does anyone have a fix for this.
2nd question. We don't need runAsp if we can hide the mapped drive. Does anyone know how to do that in like a bat file.
thank you
|
|
|
|
|
<blockquote class="FQ"><div class="FQA">Cory Kimble wrote:</div>My question, runAsp Professional does not work with Vista. Does anyone have a fix for this.</blockquote>
How about asking the people who wrote runASP Pro?
What do you mena by "hiding" a share?? All you have to do to make a share not appear in the browser is end the name of the share with a $. But, it's still possible for users to get at it if they know what the name is.
|
|
|
|
|
I am working with someone else project. The have a bat file that does a net use to map a drive to the server so it can run a dBase program.
net use y: \\server\eqdb$ /user:****\**** 3qvf0#WL
This creates the drive but it can be seen in my computer.
When we use runAs Professional (not compatible with vista) it hides or does not display the drive.
Is there a way to do that with just the microsoft runas command line feature? Any ideas. We just want a way so someone can't go in and delete the drive on the server.
Thank you.
|
|
|
|
|
Cory Kimble wrote: Is there a way to do that with just the microsoft runas command line feature?
No. RunAs just executes a command line as another user. It has nothing to do with hiding mapped drives. It may be a side affect of load/not loading another users profile. That's about all I can think of.
According to the makers of RunAs Pro, there is currently no version that works on Vista.
Cory Kimble wrote: We just want a way so someone can't go in and delete the drive on the server.
Then use appropriate Share and NTFS permissions on the server instead of relying on a "hack" that may be not supported in future versions, or patches, of Windows.
There is no command that just "hides" drive letters.
|
|
|
|
|
I found a program that can hide drives. TWEAKUI for XP and TWEAKVI for Vista
|
|
|
|
|
Ohh!! I though you were talking about hiding the share the drive mapped to.
Well, there is nothing special about TWEAKUI. All it does is make changes to the registry. You can "hide" drive letters just by modifying a regsitry value. Here...[^]
|
|
|
|
|
1. How do I move a form to the top (above other forms) but not keep it there (not .topmost)
2. Is it possible to trap the X (close form) event on the top bar such that the form doesn't actually close but rather does something else?
Thanks
|
|
|
|
|
on 1. yourForm.BringToFront
on 2. There is the Closing-event for your form (formClosing in vb2005). In that event use e.cancel=true to prevent the form from being closed.
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
|
I'm writing an app that uses report viewer to create a detail report.....sorta like a invoice, where it lists the company name and all that they bought and an image of the item they bought. So I created my report and the sub-report for the details section. However when I go to run it I get the company name but the details section grabs all parts for all companies then the break on the next company....then repeats.
Isn't there something else that is better than this? And I cannot believe that there is no one around me that has never used this...how are all these apps getting written that are using some report?
thanks for letting me vent. Any suggestion would be appreciated. And by the way I am passing the key as a parameter from the main report to the sub.
Tom
Tom Wright
tawright915@gmail.com
|
|
|
|
|
|
Dave I was looking into that but I don't know....do I need to install something special on the end users PC in order to get the report to work?
Tom
Tom Wright
tawright915@gmail.com
|
|
|
|
|
Yes, the CR runtime. The higher Visual Studio editions comes with it and the development tools in the ToolBox.
|
|
|
|
|
Tom Wright wrote: However when I go to run it I get the company name but the details section grabs all parts for all companies then the break on the next company....then repeats.
That's because you pulled (or push) all the data. You need to get only the data you want to display and group them correctly.
|
|
|
|
|
The following code throws the error above.
Module Base
Public sub Clock
Do
If needsNewChart = True
Draw = New clsDraw("clock", i_id, True)
thdWorkerSub = New Thread(AddressOf Draw.DoIt)
thdWorkerSub.Name = "Draw"
thdWorkerSub.Start()
thdWorkerSub.Join()
Draw = Nothing
End If
Thread.Sleep(100)
Loop
End Sub
End Module
Public Class clsDraw
Public Sub DoIt
'491 lines of code that creates a new bitMap(theBmp) and draws a stock market "tick chart".
'There are two uses of Monitor.Enter > Monitor.Exit on other objects without difficulties in this code.
Try
lockedGraphics = Monitor.TryEnter(theFrm.bmpTicks, 50)
If lockedGraphics = True Then
theFrm.bmpTicks = theBmp
End If
If lockedGraphics = True Then
Monitor.Exit(theFrm.bmpTicks)
End If
Thread.Sleep(10)
theFrm.pbTicks.Invalidate()
Catch ex As Exception
Ers.Show(c_id & "theTks.Draw.DoIt-setdown2", ex)
End Try
End Sub
End Class
Monitor.Exit(theFrm.bmpTicks) throws the error.
When you step through the code in the debugger, the lock is acquired and the bitmap is copied.
I use Monitor to synchronize my threads in many programs that work together to track the stock market.
I have not encountered this error before.
Why is it occuring?
Thanks.
RCarey
RCarey
|
|
|
|
|
Whoops! Solved the problem.
My code changed the object that I had a lock on. Monitor looses track of which object has the lock. Exit tries to unlock the new bitmap which does not have a lock and then throws the error.
The solution is to create a seperate locking object for monitor to lock, then change the bitmap, and unlock the object. Other procedures use the locking object also.
Works.
Thanks
RCarey
RCarey
|
|
|
|
|
Hello, This is perhaps not the best forum to post this but I've already posted to Microsoft's programming forum but have not recieved a reply.
I have a question about the "wdPropertyTimeLastSaved" property in VBA for word. I have
attached a userform with the following code in the initializing section of my
project. The form is associated with a template that displays the form when
the template is used. Essentially it displays text right on the form itself,
containing the date that the template was last saved. It works great.
However, there is a wrinkle in my design. Whenever, I make changes to either
the template or the form, I am prompted each time I use my template, to save
the template even though I did a save. I found a way around this problem, but
I don't care for the solution. I must go into the VBA editor and run the form
at least once and then save the associated template. That does the trick. No
more prompts to save the template. However, I do not want casual users to
have to go thru this extra work each time a change is made to the template
and/or form.
If you place this small snippet of code below in your own forms, you will
know what I'm talking about. Any suggestions? Thanks.
lblUFdate.Caption is an actual caption on my form which displays the date.
Private Sub UserForm_Initialize()
Dim SavedTime As Date
SavedTime = ThisDocument.BuiltInDocumentProperties( _
wdPropertyTimeLastSaved).Value
lblUFdate.Caption = "Last Updated " & Format(SavedTime, "dd-mmm-yyyy
HH:mm AM/PM")
End Sub
|
|
|
|
|
hi all,
how can i read the serial number(not volume serial number) of hard disk (not disk drive) using vb.net, that will works on any windows version - WinME, Win2K, WinXP etc.
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|