|
you haven't said what the database is
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
|
|
|
|
|
Either Paradox 5.0 or DBaseIV format - which would you recommend?
Bastard Programmer from Hell
|
|
|
|
|
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"
|
|
|
|