|
There is nothing that will do it for you. You have to maintain two copies of the array yourself. There is nothing in the .NET Framework that will do it for you. The first is your original, unsorted version. The second is a copy of the first one, but sorted.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
You may sort the array using a further level of indirection, i.e. suppose you have myArray(10) the you use another array index(10) of integers and sort myArray so that myArray(index(i+1)) > myArray(index(i)) . Having done that you retain the original values in myArray .
hope that helps.
-- modified at 9:22 Saturday 30th December, 2006
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
I am trying to connect to a MySql database using vb.net but I keep getting this error:
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
Here is my code:
Dim TimeStamp As String
TimeStamp = Format(Now(), "dd/MMM/yyyy HH:mm")
Dim myConnString As String = "Data Source=testship;User Id=jsimmons;Password=dway1207;"
Dim myInsertQuery As String = "INSERT INTO ls_orderitems (OrderItemID, OrderDate, OrderCustomer, OrderAcctNum, OrderType, OrderSoNum, OrderItemPartNum, OrderItemPartDesc, OrderItemQty, OrderItemQtyRec, OrderItemQtyDtRec, OrderItemBO, OrderItemBODt,OrderItemCanceled, OrderItemCanceledDt, OrderItemNotes, OrderItemPONum, OrderItemRetailPrice, OrderItemSalePrice, Status, InsertDate) VALUES('" & Trim(OrderItemID) & "','" & Trim(OrderDate) & "','" & Trim(OrderCustomer) & "','" & Trim(OrderAcctNum) & "'," & "'" & Trim(OrderType) & "'" & ",'" & Trim(OrderSoNum) & "','" & Trim(OrderItemPartNum) & "','" & Trim(OrderItemPartDesc) & "','" & Trim(OrderItemQty) & "','" & Trim(OrderItemQtyRec) & "','" & Trim(OrderItemQtyDtRec) & "','" & Trim(OrderItemBO) & "','" & Trim(OrderItemBODt) & "','" & Trim(OrderItemCanceled) & "','" & Trim(OrderItemCanceledDt) & "','" & Trim(OrderItemNotes) & "','" & Trim(OrderItemPONum) & "','" & Trim(OrderItemRetailPrice) & "','" & Trim(OrderItemSalePrice) & "','" & Trim(Status) & "','" & Trim(InsertDate) & "','" & TimeStamp & "'" & ")"
Dim myConnection As New SqlConnection(myConnString)
Dim retvalue As Integer
Dim myCommand2 As New SqlCommand(myInsertQuery, myConnection)
myConnection.Open()
retvalue = myCommand2.ExecuteNonQuery()
myConnection.Close()
Any advice will help.
jds1207
|
|
|
|
|
You say you're using MySQL, but your code say's your using SQL Server. Which is it? You can't use the Sqlxxxx objects on a MySQL server, you have to use the OleDbxxxx objects instead.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
You need to go into the Sql Server Configuration Manager and set it up to allow remote connections.
jds1207 wrote: MySql database using vb.net ... error:
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005
MySQL and SQL Server 2005 aren't the same database
|
|
|
|
|
I do not know how to do this project
please help
I do not how to do the code
<the project="" is:="" create="" a="" name="" backwards="" application="" that="" prompts="" the="" user="" to="" enter="" his="" or="" her="" (in="" textbox="" not="" inputbox)="" and="" then="" displays="" in="" all="" lowercase="" label="">
|
|
|
|
|
Don't think of the name as a name but instead a collection of char's.
The StringBuilder object will take the text and allow you to reference each char in it using it's position in the array.
So when you create an newSB as new stringbuilder("abc")
what you really have is
newSB(0)=a
newSB(1)=b
newSB(2)=c
Now if we went old school(kind of)
you would create an arraylist newSA as new arrayList()
'This loads the ArrayList up
For ctr As Integer = 0 To Label1.Text.Length - 1
newSA.Add(Label1.Text.Substring(ctr, 1))
Next
' This unloads the ArrayList into a label stepping down the arraylist
For ctrOut As Integer = sa.Count - 1 To 0 Step -1
Label2.Text += newSA(ctrOut).ToString()
Next
This sounds very much like homework but you cannot just brush over this it is to important. What you are exploring is how the variables are really just memory locations and you can address them many different ways. To prove the point lets shrink the example.
' This unloads the TextBox into a label stepping down the String
For ctrOut As Integer = TextBox.Text.Length - 1 To 1 Step -1
Label2.Text += TextBox.Text.Substring(ctrOut, 1)
Next
So there you go a lengthy discussion on what strings are but if you are going to learn how to program get to the real meaning of what they are asking you to learn.
Hope this Helps
|
|
|
|
|
I have just completed a course in programming VB.NET with DeVry and I really like it. I want to write a program for a blackjack game. I have 2 arrays set up for the deck of cards, one for the card name (ex. 3-Hearts) and the other for the card value (ex. the 3-Hearts = 3).
I'm starting small and I only want to deal 2 hands (user and dealer). My question is:
Is there a better way to generate 4 random numbers from 1 - 52 so that you do not get the same number twice? Of course, for drawing other cards in the hand I'll need additional random numbers.
This is what I have and it seems to work, but is there another (better, shorter) way?
Randomize() 'Initialize random number generator.
Do
intCard1 = CInt(Int((51 - 0 + 1) * Rnd() + 0)) 'Random generate 1st number.
intCard2 = CInt(Int((51 - 0 + 1) * Rnd() + 0)) 'Random generate 2nd number.
Loop Until intCard1 <> intCard2 'Loop if cards are the same.
Do
intCard3 = CInt(Int((51 - 0 + 1) * Rnd() + 0)) 'Random generate 3rd number.
Loop Until intCard3 <> intCard1 And intCard3 <> intCard2
Do
intCard4 = CInt(Int((51 - 0 + 1) * Rnd() + 0)) 'Random generate 4th number.
Loop Until intCard4 <> intCard1 And intCard4 <> intCard2 And intCard4 <> intCard3
Thanks in advance for any assistance!
Mike
|
|
|
|
|
The trick is simulating what happens in real world.
Suppose you have to extract five (distinct) numbers from fifty ones.
You first initialize an array
For n=1 to 50
num(n)=n
next n
then you extract the five numbers into the extracted array
for k=0 to 4
r = CInt(50 * Rnd() + 1 - k))
extracted(k) = num(r)
swap(num(r), 50 - k )
next k
As you can see, each time the extracted value is swapped with the element at the and of the array and the following choice is done on a narrowed array.
Hope that helps (I wrote the code remembering the algo, i.e. I did not verify it, only to illustrate the algo itself).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Thanks for the prompt response. I thought I would try a small program using your suggestion just to see if I could generate the random numbers to a msgBox, but I get the dreaded blue squiggly line under "swap" and the message says that the "expression is not a method". Any ideas on this?
Thanks again,
Mike
|
|
|
|
|
If there is no method to swap two variables then you have to manually swap them, i.e.
swap(a,b)
is equal to the following statements:
tmp=a
a=b
b=tmp
where tmp is a temporary variable.
hope that helps
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
This is the error message that i receive when i go to run the program.
Windowsapplication1 has encountered a problem and must shut down.
Error Signature:
EventType: clr20r3 P1:applaunch.exe P2: 2.0.50727.42
P3: 4333ab62 P4:starch P5:1.0.0.0 P6: 45952711 P7:e
P8: e9 P9:system.invalidoperationexception
|
|
|
|
|
There's no way to tell from that information. There's LOTS of possible causes, including making cross-thread calls in .NET 2.0 that are no illegal but worked fine under .NET 1.x. Messing up the references section of your code. Interdependencies of any controls your using, like using the Office 11 PIA's and only having Office 10 installed. Controls that depend on other libraries that don't exist on the target machine. ...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
anyway to further identify the problem?
|
|
|
|
|
Nope. The data that's in the message is just the data of the message itself.
If you can get a debugger attached to it you're well on your way to finding the cause. The problem is that most of the time, this error happens right at startup, which would lead me to believe that there is a dependancy problem.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
ok so this might be a stupid question, but how do i go about getting a debugger attached to the program
|
|
|
|
|
Create a test machine that replicates the problem, then install VS.NET on it. Or setup a remote debugging session so you can attach your development machine to the process on a remote machine. But, you have to launch the code to get the process running before you can attach the debugger to it. Like I said, if it crashes immediately upon launch, you're not going to get a debugger going and attached.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi all,
Can I run vb code and com components in Unix, Lynux and Solaris operating systems. I need complete information
Thank you,
S/W Engineer
Akebono Soft Technologies
aleem_abdul@akebonosoft.com.
|
|
|
|
|
No.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I am using bound DataGridView with vb.net 2005 Express edition.
First I add the database to the project
Then I select the table which I want on the form and drag it on the Form.
I drop it there and a DataGridView comesup with the toolbar on top.
The problem is that Update/Save doesn't work.
Update button has following code beneath itself
Private Sub MainBindingNavigatorSaveItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MainBindingNavigatorSaveItem.Click<br />
Me.Validate()<br />
Me.MainBindingSource.EndEdit()<br />
Me.MainTableAdapter.Update(Me.PipeDataSet.Main)<br />
<br />
End Sub
can someone help, Please
Think, and it can be done
|
|
|
|
|
Hi all,
HiEdit V1.0.1.4 has been released. HiEdit is a multi-tabbed, high speed, large file edit control. It uses no more than ~140K of memory due to its sophisticated memory management. It supports most standard edit/richedit control messages and many custom ones. You can use it with any programming language since it is packaged as a standard dll and a static library. A full source demo application (written in Assembly) is inluded. You can get it at http://www.winasm.net/index.php?ind=downloads&op=entry_view&iden=151. I am currenlty writting a demo application in VB6 which I plan to upload soon.
In addition, you can get HiEditor V1.0.1.5 (a full blown application that uses HiEdit).
Any feedback/suggestions is highly appreciated
Regards,
Antonis Kyprianou
http://www.winasm.net
|
|
|
|
|
What is it about "No advertising or soliciting" that is beyond your comprehension?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I apologize if this post is considered as an ad. Please, admins, delete this post. How does one let other programmers know about a free project (open source or not) without being considered as an ad?
http://www.winasm.net
|
|
|
|
|
akyprian wrote: How does one let other programmers know about a free project (open source or not) without being considered as an ad?
Write an article about. But then, please, don't advertise the article.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
I see. Sorry for the inconvenience. I was not aware of how things work here.
Thanks for your kindness to explain,
Antonis
http://www.winasm.net
|
|
|
|