|
Daffodil database[^]
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
EDIT: Sorry I misread the question.
Could you iterate through the collection
For i As Integer = 0 To table.count - 1
Dim selected As Row = table.row(i)
newTable.add(New Row(i, selected.FirstName, selected.LastName, Occupation))
Next
Alternatively if you are adding to existing table you could use a GUID
For i As Integer = 0 To table.count - 1
Dim selected As Row = table.row(i)
newTable.add(New Row(Guid.NewGuid(), forstName, LastName, Occupation))
Next
- Use the database primary key and store in a column those width is 0.
- Some table rows have a tag property you can use to store the entity representing the record
- Some tables are bound directly to a data source, so by querying the selected row, you can access the unique Id.
For a more specific answer, you'll need to detail the scenario. At this stage we don't even know if your talking about a DataGrid, a DataTable or some other matrix type object.
"You get that on the big jobs."
|
|
|
|
|
I have a table. It desn't have any Id which will be generated automatically.
my table (Table1)has 30 some rows and 3 columns(FirstName, LastName, Occupation).
I want to read each row one by one and wanted to create a unique ID which is of type uniqueIdentifier and fill another table with all these coulmns and newly created ID.
How can I do that
|
|
|
|
|
Why row by row, and not all at once?
SELECT NEWID()
, [FirstName]
, [LastName]
, [Occupation]
INTO MyNewTable
FROM MyExistingTable
--edit;
You would have received more answers if you posted this in the Database[^]-forum.
Bastard Programmer from Hell
|
|
|
|
|
That is according to MSDN[^]
I don't understand is... why? I am sure the answer is probably very simple, but for some reason my mind can't come up with the answer. Maybe it's cuz I am so frustrated with this error. Well, who knows.
What do I want to achieve?
Suppose the following...
Public Sub ChangeThePictureBoxBC(Optional newColor as System.Drawing.Color = Drawing.Color.Black)
Me.SomePictureBox.BackColor = newColor
End Sub
This does not seem wrong to me. Can someone please explain A) why the above sub is wrong without re-quoting the unhelpful MSDN document and B) what suggestion/advice can you give me to make an optional parameter that involves color.
Thanks in advance.
|
|
|
|
|
Clark Kent123 wrote: A) why the above sub is wrong
Only nullable types can be used as optional parameters; a struct is a value-type and can't be empty.
Clark Kent123 wrote: B) what suggestion/advice can you give me to make an optional parameter that involves color.
Overloading[^], instead of optional parameters;
Public Overloads Sub ChangeThePictureBoxBC(newColor as System.Drawing.Color)
Me.SomePictureBox.BackColor = newColor
End Sub
Public Overloads Sub ChangeThePictureBoxBC()
Me.SomePictureBox.BackColor = Drawing.Color.Black
End Sub
Bastard Programmer from Hell
|
|
|
|
|
Overloading! Yeah, that's probably the direction that I will go in. Great suggestion!
|
|
|
|
|
Thanks
|
|
|
|
|
I'm reading a range from VBE code in a spreadsheet.
data = mySheet.Range(a1:a8).value
but I need to get data as Double() and not as Variant
I need something like:
Dim data() as Double
data = mySheet.Range(a1:a8).value
this because I will use data as c# arg of Com addins (double[])
Thanks for your time
|
|
|
|
|
TheGermoz wrote: this because I will use data as c# arg of Com addins (double[])
I haven't scripted that much yet, but wouldn't it be easier to change the params of the Com addins to (object[])?
Put a breakpoint on it, and see if you can cast/convert it to double's.
Bastard Programmer from Hell
|
|
|
|
|
thanks you for your replay. Com addin is shared with other application. so not so easy.
It is surprising that from VBE code in spreadsheet it is not possible to copy an Excel range into an array of double() with one dimension.
|
|
|
|
|
TheGermoz wrote: data as Double() and not as Variant
Have you tried Array.Copy?
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
Array.Copy() is not available from VBE but from VBA/C#, so I need to change the COM addin..that is shared with other application...
|
|
|
|
|
How to Convert MS Word 2003 doc to PDF
|
|
|
|
|
|
|
I am currently in the process of learning the vb.net environment after spending a number of years using VB6.
I took one of my straight forward single threaded apps in VB6 and used the upgrade wizard to convert this app to .net. I've got most of the conversion issues resolved, but I am now getting messages warning about accessing objects from a thread different than the one that created the object. So I'm a bit confused since the original VB6 app - which works fine by the way - had only one thread.
Why am I getting these sorts of messages? I've searched through the code - with my limited exposure to multithreading - and not found anything obvious that I've somehow created a Hydra from a single snake.
My preference would be how to "just make it simple" - a single threaded .net app. All of the references I find to multithreading talk about how to do it. I really - at least at this point - want to know how to avoid it.
I know that soon I will wade in and learn multithreading, but I'd like to do it on my terms.
Any ideas? Pointers to some reference material?
Thanks,
Rick
|
|
|
|
|
simple answer is to remove the
dim myThread as new thread(addressof ThreadCodeSubRoutine)
myThread.Start
and replace it with the call to the ThreadCodeSubRoutine . But .NET introduced thread saftey so you have to invoke a routine to update the controls that are on your form. a bit similar to
Delegate Sub UpdateMyForm(byref SomeValue as string)
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
dim MyThread as new thread(addressof MyThreadCode)
MyThread.start("HI")
End Sub
Private MyThreadCode(byval Message as string)
dim DelegateVariable as new UpdateMyForm(Addressof WriteToLabel)
me.Invoke(DelegateVariable, Message)
End Sub
Private Sub WriteToLabel(byval Message as String)
label1.Text = Message
end sub
But Also have a read of this MSDN Control.Invoke Method (for Threads use)[^]
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
Ah, but here's the rub... there is no command in the code that invokes a new thread. I searched through the entire project looking for "thread" or "addressof" and found nothing. That's what gotten me perplexed - can't seem to find out how or where the second thread (if there is one) gets created.
The messages mentioning threads are related to updating form objects, so should I assume that the "thread safety" is the culprit here? In other words, even for a simple single threaded application, do I need to create a separate thread to handle form updating?
Rick
|
|
|
|
|
|
You're going to have to show the code that's throwing up the errors. I've never seen a case where the conversion wizard generates threaded code on its own.
|
|
|
|
|
There are some possibilities to run into multi-threading without directly intending it.
When you communicate with other applications (e.g. an outproc COM server), events can come from other threads.
If you use the application framework for running only one instance of your application, a second start of the application will send the calling parameters to the running application in a different thread.
Use the Invoke /BeginInvoke function to transfer the call into the main thread.
|
|
|
|
|
How to Add 3 columns from database to ComboBox, I want to visible 2 of them I use this
reader = OleDbCommand1.ExecuteReader()
Dim dt = New System.Data.DataTable()
dt.Load(reader)
ComboBox2.DataSource = dt
ComboBox2.DisplayMember = "column1"
ComboBox2.ValueMember = "column3"
ComboBox2.SelectedIndex = -1
reader.Close()
this work
but can I use this
ComboBox2.DisplayMember = "column1" + "column2"
|
|
|
|
|
in a nutshell you have create a custom class from combobox to do it
have a read of this Multiple columns combo box vb.net[^]
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
I have a VB application I wrote in 2002 with Visual Studio 2002 at that time. It copies files and directories with a variety of parameters. We use the utility to copy files from server to server or destktop to desktop via scheduled tasks, etc.
It is a framework 1.0 app and has worked for years. This past year it was evident it needs upgraded to VS 2010. Everything is working fine except in Windows 7 with parameters we've used for years with XP and on the servers, when we copy a root directory, for example, D:\, the copy program will try to copy the Recycle Bin and the System Volume Information and fail. In previous operating systems I'm guessing it didn't try to copy these items, but in Windows 7 for some reason it does.
We really don't want to copy these two items anyhow, so in the new VS VB 2010 code I wrote the following logic, but I've found that from one server it isn't working:
<br />
Dim source as string = "D:\"<br />
Dim currentDirectory As DirectoryInfo = New DirectoryInfo(source)<br />
Dim di As DirectoryInfo<br />
For Each di In currentDirectory.GetDirectories()<br />
If blnIsRoot = True Then<br />
If (di.Attributes = FileAttributes.Normal) Or _<br />
(di.Attributes = FileAttributes.Directory) Or _<br />
(di.Attributes = FileAttributes.SparseFile) Or _<br />
(di.Attributes = FileAttributes.ReparsePoint) Or _<br />
(di.Attributes = FileAttributes.NotContentIndexed) Or _<br />
(di.Attributes = FileAttributes.System) Or _<br />
(di.Attributes = FileAttributes.Offline) Or _<br />
(di.Attributes = FileAttributes.Temporary) Or _<br />
(di.Attributes = FileAttributes.Device) Or _<br />
(di.Attributes = FileAttributes.Hidden) Or _<br />
(di.Attributes = FileAttributes.Encrypted) Or _<br />
(di.Attributes = FileAttributes.Compressed) Or _<br />
(di.Attributes = FileAttributes.Archive) Or _<br />
(di.Attributes = FileAttributes.ReadOnly) Then<br />
<br />
.... logic to copy directory<br />
<br />
end if statments, next statements, etc...<br />
With this code, it will copy a root directory (d:\) and all sub directories and ignore the recycle bin and system volume information.
Code works 99% of the time, but with one server which houses our intranet, I'm copying from \\inttranetserver\wwwroot\dept\its\ to d:\test\ and it is not copying any directories at all, even though there are multiple under ..\its\
I run the code in debug, set breakpoints and skip the if statement (shown above) checking attributes and it works fine, but put that if statment back in it doesn't copy any of the directories.
I'd like to use better logic, for example something that checks for "if recycle bin or if system volume information" but I haven't found anything.
Any suggestions?
Thanks
Lost in the vast sea of .NET
|
|
|
|