|
A structure should generally be immutable, and the point of using a structure is mostly defated as you have a reference type inside it. Use a class instead of a structure.
Public Class UserInfo
Public ID As Integer
Public Name As String
End Structure
Dim Users As New List(Of UserInfo)
Users.Add(New UserInfo With {.ID = 1, .Name="Jim"})
Users.Add(New UserInfo With {.ID = 2, .Name="Bob"})
Users.Add(New UserInfo With {.ID = 3, .Name="Sue"})
Now you don't have to remove and add the item to update it:
(From UserInfo In Users Where UserInfo.ID = 3 Select UserInfo).First.Name = "Susan"
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi Guffa,
Thanks for the reply - some very useful information in there. I do have one small problem though - I cant find the correct syntax for the update:
(From UserInfo In Users Where UserInfo.ID = 3 Select UserInfo).First.Name = "Susan"
It doesnt work on its own in VB 2k8, and after hours of net searching, I cant find the answer . Using:
dim b as boolean = (From UserInfo In Users Where UserInfo.ID = 3 Select UserInfo).First.Name = "Susan"
compiles, but obviously doesnt update anything (the expression above supposedly returns a boolean)
If you get chance, and you know the answer, can you post a quick message telling me...
Ta muchly!
|
|
|
|
|
I thought that the LINQ expression could be used as an expression, but obviusly it can't. If you put the result in a variable, it works:
Dim user As UserInfo = (From u In Users Where u.ID = 3 Select u).First
user.Name = "Susan"
Another way to do this (and more effective as it only looks until it finds the first occurance) is to use a lambda expression:
Users.Find(Function(u) u.ID = 3).Name = "Susan"
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi Guffa,
Thanks for that - you have been a huge help!
I cant believe I didnt try option 1 first though I think I tried everything but!
|
|
|
|
|
hi
in may project i exploit my data to exl sheet but the styel not very will because the size of the sill is smailer than data size
is their is way to make the sill size larger in my code not from the excel?
|
|
|
|
|
asha_s wrote: in may project i exploit my data to exl sheet but the styel not very will because the size of the sill is smailer than data size
It's "export my data", not "exploit".
asha_s wrote: but the styel not very will
Are you saying that the cell formatting isn't correct??
asha_s wrote: the size of the sill is smailer than data size
Are you saying the size of the CELL, not "sill", is too small to fit the width of the data?
asha_s wrote: is their is way to make the sill size larger in my code not from the excel
You can't do it in your file, but you can use the Excel object model to do this. You would need either the Visual Studio Tools for Office (recommended) or add a reference to the Excel x.x Object Model. This method requires that you have a good working knowledge of Excel and it's object model to do this.
|
|
|
|
|
Hi,
I was wondering, is there any way to execute code [a procedure, for example] at a specified system time [say 11:45:30] without having to use a timer to check system time every x seconds?
Thanks !
Kazz
"Users are there to click on things, not think. Let the archs do the damn thinking."
|
|
|
|
|
Ariel Kazeed wrote: without having to use a timer to check system time every x seconds?
Well, you could use the task scheduler in windows to run your app. If you use a timer, you can set it to first check every 12 hours, then every 8, etc, you can make the timer smaller as the interval to go is less.
Christian Graus
Please read this if you don't understand the answer I've given you
"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 every one...
I just came across a property of picture box called initialimage... when i read the description it says "Image to be displayed while another image is loding"
I had a issue that when i am getting a image to be displayed from DB it is taking lot of time delay...
I taught may be by this property i can load a image saying "Loading Image.... " or something like that... that will make the application a lot more presentable...
But i am not able to use it
Can some one please help me with it
Regards
Nishkarsh
|
|
|
|
|
The property is just an image, so you'd load an image from the file system or resources and set that property. You can probalby also browse direct to an image on the file system in your designer and it will take care of it for you.
Where are you stuck ?
Christian Graus
Please read this if you don't understand the answer I've given you
"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 )
|
|
|
|
|
I think the way i am doing the application is not proper...
what i am doing is...
form load
{ Get image from DB as byte stream
load the byte stream in the picture box
}
The application is not completing the form load till the image is not loaded... so the form is also not displayed properly...
So even the initialImage will not also been shown...
Is there any other way... may be initiate a thread or something to get the image from DB and load it in picture box...???
Regards
Nishkarsh
|
|
|
|
|
The initialimage should not come from your DB, but from your resources.
Christian Graus
Please read this if you don't understand the answer I've given you
"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 )
|
|
|
|
|
the initialidate image is not coming from Db
What i want to do is... show the initialimage till it lodes the actual image from DB so the delay dose not looks bad...
|
|
|
|
|
The initial image isn't showing up because the drawing of the Form (in Form_Load) hasn't completed, but the UI thread is now blocked running your database code retrieving an image. Since the UI thread is blocked, it can't process any of the WM_PAINT messages for the form or it's controls, and hence, you won't see the initial image.
Just remember, any code running in Form_Load runs before the form is painted.
|
|
|
|
|
Are you getting the image from a database and then assigning it to pictureBox.image?
I assume (but am not certain) that if you use PictureBox::Load(string Url) this is when an initialImage is displayed. If you are not loading and just retreiving the image from a database and then assigning it to a PictureBox.Image (using PictureBox.Image = dbImage) then whilst you are retreiving the image the image is not really loading.
If this is not the case then search MSDN it will tell you a lot more than I can.
At university studying Software Engineering - if i say this line to girls i find they won't talk to me
Dan
|
|
|
|
|
Add you initial image to your project resources. Then set the initialImage property to the image from the resources.
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
Hi
This is my Vb6 code
---------------------------------------
Dim oOu As IADsOU
Set oOu = np.OpenDSObject("LDAP://" & "OU=DC" & strLDAPEnd, vbNullString, vbNullString, ADS_SECURE_AUTHENTICATION)
For Each child As ActiveDs.IADs In oOu
Next child
----------------------------------------
This code is Working in VB6.But When i upgraded it to VB.net .I am geting an error saying that 'oOu' is not a collection type..
What is the wrong in this
Thanks
Chaitanya
modified on Friday, May 9, 2008 3:17 AM
|
|
|
|
|
I dont know what IADsOU is but I dont think it is a collection type. Foreach works on collection types. Try using a for loop to iterate through it instead.
At university studying Software Engineering - if i say this line to girls i find they won't talk to me
Dan
|
|
|
|
|
IADsOU is a ActiveDS method ..
In VB6 code it working good but inVB.NET ..not ..
|
|
|
|
|
foreach only works on .NET classes that impliment IEnumerable. If this is some sort of collection and I assume it is, it's not one that supports foreach. Just do a normal for loop instead.
Christian Graus
Please read this if you don't understand the answer I've given you
"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 everybody in the problem solving world !!!!.........
Well I have come across a unique problem and am not able to find any logic behind that.
My vb.net application runs on a sql server 2000 and it is about making bills in a fast running gift counter with 5 to 6 client and server is placed at a distance of 200 meters. The store sells maximum of 50-60 gifts. The user does all the transaction through clicks.
Two tables are involved for making a transaction. One is mastertable and detailtable.
In the mastertable my application is inserting the total of the bill, date, amount and the counter person’s code. It then generates an auto number which I picks up after the data is inserted in the mastertable and then uses the same in the detailtable.
The detailtable holds fields like item, qty, rate,id of mastertable etc.
My application is running smooth, but recently I noticed that say one in 500th time, row is not added to mastertable while it is present in detailtable with the id of mastertable. I have binded the sql with commit. I have digged my code but am not finding any logic behind this error.
Please help. Thanks in advance.
|
|
|
|
|
If your detail table uses an id that refers to the master table, then the code to get that id must be broken, or the record is getting deleted. Do they have a foreign key relationship in your DB ?
Entering it all in a single transaction, in a stored proc, is the best way to do this
Christian Graus
Please read this if you don't understand the answer I've given you
"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 )
|
|
|
|
|
Hi,
There are many Cases of Generation this type of Problem
Like
Many time Open Connection
Sql Query Error
Database Field Property Error
Can U Send Me Query and Database Table Property.I Can Halp U.
Thanks
Anubhava Dimri
919250168195
|
|
|
|
|
Here is the code:
con = connect()
con.Open()
'transaction begins here-------
trans = con.BeginTransaction()
Try
'Data is inserted into mastertable---------
cmd = New SqlClient.SqlCommand("INSERT INTO mastertable(mbno,mbdate,mbamount,mbcperson) VALUES(" & counter_bill_no & ",'" & server_date & "'," & billvalue & "," & countercode & ")", con, trans)
cmd.ExecuteNonQuery()
cmd = New SqlClient.SqlCommand("select mbid from mastertable WHERE mbno=" & counter_bill_no & " and mbcperson=" & countercode & " ", con, trans)
mb_id = cmd.ExecuteScalar
'Data inserted into detailtable-----------
i = 0
For i = 0 To row_no - 1
selling_rate = DataGridView1.Item(2, i).Value
If selling_rate <> 0 Then
cmd = New SqlClient.SqlCommand("INSERT INTO detailtable(dbno,dbdate,dbicode,biquantity,dbamount) VALUES(" & mb_id & ",'" & server_date & "'," & DataGridView1.Item(4, i).Value & "," & DataGridView1.Item(1, i).Value & "," & DataGridView1.Item(3, i).Value & ")", con, trans)
cmd.ExecuteNonQuery()
End If
Next i
'Data commited--------
trans.Commit()
Catch ex As Exception
trans.Rollback()
MsgBox("Bill could not be generated, Please try again.")
End Try
con.Close()
|
|
|
|
|
Thanks.
Well my table as yet doesnt have the foreign key relationship. This is the code am using at present:
con = connect()
con.Open()
'transaction begins here-------
trans = con.BeginTransaction()
Try
'Data is inserted into mastertable---------
cmd = New SqlClient.SqlCommand("INSERT INTO mastertable(mbno,mbdate,mbamount,mbcperson) VALUES(" & counter_bill_no & ",'" & server_date & "'," & billvalue & "," & countercode & ")", con, trans)
cmd.ExecuteNonQuery()
cmd = New SqlClient.SqlCommand("select mbid from mastertable WHERE mbno=" & counter_bill_no & " and mbcperson=" & countercode & " ", con, trans)
mb_id = cmd.ExecuteScalar
'Data inserted into detailtable-----------
i = 0
For i = 0 To row_no - 1
selling_rate = DataGridView1.Item(2, i).Value
If selling_rate <> 0 Then
cmd = New SqlClient.SqlCommand("INSERT INTO detailtable(dbno,dbdate,dbicode,biquantity,dbamount) VALUES(" & mb_id & ",'" & server_date & "'," & DataGridView1.Item(4, i).Value & "," & DataGridView1.Item(1, i).Value & "," & DataGridView1.Item(3, i).Value & ")", con, trans)
cmd.ExecuteNonQuery()
End If
Next i
'Data commited--------
trans.Commit()
Catch ex As Exception
trans.Rollback()
MsgBox("Bill could not be generated, Please try again.")
End Try
con.Close()
As for Stored Procedures, i dont know much about it, what are the advantage of them.
Regards.
|
|
|
|
|