|
You might want to try WMI and the System.Management namespace. You can get a reference to the disk controler driver and TRY to disable it, it works kind of like a service where you can Start, Stop, Pause,... But, if I remember right, it doesn't actually work properly with drivers.
But instead of going through all this pain, why not use B: instead of A:...
RageInTheMachine9532
|
|
|
|
|
Hello
Does anyone know if it's possible to create the description tooltip that appears in the IDE for properties and methods etc?
I know in C# you can embedd <SUMMARY> xml tags in the source, but this does not seem to work with VB.net?
|
|
|
|
|
That functionality isn't supported in VB.NET, yet...
To do this, you'll have to either write, by hand, the .xml file that describes the stuff, like c# can generate, or, you'll have to use a third party component that creates the file for you. You can find that on GotDotNet here[^].
RageInTheMachine9532
|
|
|
|
|
Hello,
I have a filled a data set and would like to insert data from that dataset to a different table then the dataset was filled with, is there a way to do it a row at a time? If so does anyone have an example?
Thank you,
Santana
|
|
|
|
|
Would you elaborate more?
If I am correct, then this is what you want to happen:
dataadapter.fill(dataset,"Table1")
'do inserts into the dataset
'now you want all the inserted rows to be saved to Table2! True?
'If you are using update command on dataadapter, then you would be able to only save the rows to Table1
dataadapter.update(dataset) 'this will save rows to Table1
if you want these rows to be saved into another table (Table2) then create another dataadapter + dataset for that table, copy dataset1 to dataset2 and then call update on dataadapter2.
let me know.
Web reading made easy -
http://www.xemantex.com
|
|
|
|
|
You can use a command object to update the rows in Dataset to the second Table in database.
'assume connString = Your connection string
Dim cn as new OledbConnection(connString)
Dim cmd as new OledbCommand
cmd.Connection = cn
cn.Open
dim i as integer
For i=0 to DataSet1.Tables(0).Rows.Count-1
cmd.CommandText = "INSERT INTO Table2 (Col1,Col2,Col3,..) VALUES (DataSet1.Tables(0).Rows(i).Item(1),DataSet1.Tables(0).Rows(i).Item(2),DataSet1.Tables(0).Rows(i).Item(3)....)
cmd.ExecuteNonQuery
Next
cn.Close
cmd.Dispose
cn.Dispose
"I think there is a world market for maybe 5 computers"
Thomas Watson, chairman of IBM, 1943
"There is no reason anyone would want a computer in their home"
Ken Olson, chairman & founder of Digital equipment, 1977
"This 'telephone' has too many shortcomings to be seriously considered as a means of communication. The device is ingerently of no value to us."
Western Union internal memo, 1876
"640 K ought to be enough for anybody."
Bill Gates, 1981
"Computers in the future may
|
|
|
|
|
try executing an SQL command using a command object.
loop through the records in the dataset
dim x as integer
dim KKK as new oledbcommand
kkk.connection = 'write you connection here
kkk.connection.open ' if the connection is closed
for x = 0 to dataset1.tables.rows.count - 1
kkk.executenonquery("Insert into TABLENAME (field1,field2,field3) values (" & dataset1.tables(x)("field1") & "," & dataset1.tables(x)("field2") & "," & dataset1.tables(x)("field3") & ")")
next
kkk.conection.close ' just close the connection
- Casting More!!
May elune shine upon you!
|
|
|
|
|
Hi,
I'd like to create my own PDF writer in .net.
Can anyone suggest me on
-> Where to start ?
-> Tecnologies involved ?
-> Where to get samples ?
-> How to get sample source code for Pdf components ?
Pls. detail me if anyone knows abt this.
Thanks in advance.
DHARMA.R
|
|
|
|
|
The first place to start would be http://developer.adobe.com. You'll need the specifications for the format of a .PDF file. Warning: Not free...
You can look at a couple of open source projects at http://sourceforge.net[^] like PDFCreator and iText.
RageInTheMachine9532
|
|
|
|
|
Hi Dave,
Thank u v much for ur valuable help.
I will check it now.
Thanks
DHARMA.R
DHARMA.R
|
|
|
|
|
Hi , i'm a new pwerson in this forum so please give me some lessons ok..;) Here i've got some problem that i want to learn the ant algorithm, not genetic algorithm using visual basic 6. As a student, i thought this ant algorithm is very interesting to me. So does anybody in this forum can teach me about the ant algorithm using visual basic?? How it's work?? Some example?? I hope that someone can teach me ok...
Thanks.
|
|
|
|
|
We can help you with coding problems. But forums like this are not the place the be teaching entire algorithms. You'll have much better (and faster!) results searching the web for "Ant algorithm". On Yahoo, I came up with LOTS of documents and code samples...
There's even an article here on CodeProject: http://www.codeproject.com/cpp/GeneticandAntAlgorithms.asp[^]
RageInTheMachine9532
|
|
|
|
|
I am having to change my code so that I will have some subs and so that I can call on the subs. Here is my code for under the btncalculate button. Could anybody give me suggestions on how to put in subs and to change my code where it will still work.
Private Sub btncalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncalculate.Click
Dim amount As Single
'Finding out how much they will be payig just for the room - with no extras.
If radstandard.Checked = True Then
costofroom.Text = standardrate
costofroom.Text = Format(standardrate, "currency")
ElseIf raddeluxe.Checked = True Then
costofroom.Text = deluxerate
costofroom.Text = Format(deluxerate, "currency")
ElseIf radsuite.Checked = True Then
costofroom.Text = suiterate
costofroom.Text = Format(suiterate, "currency")
End If
'Figuring out how many days that they want the room.
numberofdays.Text = DateDiff(DateInterval.Day, dtparrival.Value, dtpcheckout.Value) + 1
'Finding out the cost if they need an additional bed.
Dim newcharge As Double = rollawaybed * Val(numberofdays.Text)
If chkbed.Checked = True Then
rollawaybedcharge.Text = Format(newcharge, "currency")
Else : rollawaybedcharge.Text = 0
rollawaybedcharge.Text = Format(0, "currency")
End If
'Finding out how many are going to be in the room.
'Finding out how much it is going to cost for more than 2 people in the room.
Dim additionalguest As Double = ((nudguest.Text - 2) * 10) * Val(numberofdays.Text)
If nudguest.Text > 2 Then
additionalguestcharge.Text = additionalguest
additionalguestcharge.Text = Format(additionalguest, "currency") '((((nudguest.Text - 2) * 10) * Val(numberofdays.Text)), "currency")
Else
additionalguestcharge.Text = 0
additionalguestcharge.Text = Format(0, "Currency")
End If
'Calculating just how much the room is going to cost with the number of Days staying there.
subtotal.Text = ((numberofdays.Text) * (costofroom.Text))
subtotal.Text = Format(((numberofdays.Text) * (costofroom.Text)), "currency")
'Calculating the total for the room with everything
total = CInt(CInt(subtotal.Text) + CInt(additionalguestcharge.Text) + CInt(rollawaybedcharge.Text))
txttotal.Text = Format(total, "C")
I am not sure what to do. I am confused on how to do this.
End Sub
Thank you,
ibok23
|
|
|
|
|
I was also told to move my subs around. Not sure what this means.
Thank you,
ibok23
|
|
|
|
|
well i dunno how much help this is going to be... very tired, i cant read all that right now, lol.. but
do u simply need to create subs for the fact that some1 wants you to and you dont know how?
i can start you off with this one. put this one in its own sub 4 sure. to do it, just go and cut the text from the button click event code and make another sub and paste the code in there, as shown:
private sub SetCost()
'Finding out how much they will be payig just for the room - with no extras.
If radstandard.Checked = True Then
costofroom.Text = standardrate
costofroom.Text = Format(standardrate, "currency")
ElseIf raddeluxe.Checked = True Then
costofroom.Text = deluxerate
costofroom.Text = Format(deluxerate, "currency")
ElseIf radsuite.Checked = True Then
costofroom.Text = suiterate
costofroom.Text = Format(suiterate, "currency")
End If
end sub
and to call this from the button click code, simply, in the button click event code type SetCost() . it will then go out and do the code in the SetCost method and return to the button click event where it left off.
since this section doesnt deal with any of the variables in the rest of the button click code, it can definetly b put in its own sub.
you should b able to separate the rest. just b logical about it, look thru it. ex., the ''Figuring out how many days that they want the room.' comment you have there can b cut and pasted into another new sub, called, say, RoomDays, whatever. just follow the same example as the SetCost sub. dont separate parts in2 its own sub if it has variables that are also required in the button click event.
... well, you can use functions for this rather than subs, but keep it simple for now and use subs. lol... forget that last sentence, it was more 4 other ppl reading this and yelling at me about it.
NOTE: i STRONGLY suggest (as all programmers will), since you seem somewhat new, start using camel casting for your variables. this means, when u declare a variable (anything..[to an extent].. when you NAME something), use lower case for all letters, except the 1st letter of every word after the 1st word...
ex:
costofroom should be camel casted to costOfRoom . MUCH easier for other people to read and help you debug code. prettier for the eyes. nearly a standard.
------------------------
Jordan.
III
|
|
|
|
|
Ok,
I have moved that over underneath the Private sub costofroom_textchanged section.
Now underneath the btncalculte I wrote costofroom() and I got errors.
Now what am I doing wrong?
Did I move it to the wrong section? I do not have
private sub setcost () I tried to put that under the private sub costofroom and it gave me an error.
if i need to copy it over and paste it here let me know.
Thank you,
ibok23
|
|
|
|
|
I've rewritten some of your code in your first post. It should provide a couple of examples for you to follow. You can rewrite three more sections of your original code into Functions. I'll leave it to you to figure out which sections and how to write the functions:
Private Sub btncalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncalculate.Click
'Finding out how much they will be payig just for the room - with no extras.
CalculateBaseCostOfRoom()
'Figuring out how many days that they want the room.
numberofdays.Text = CalculateDays(dtparrival.Value, dtpcheckout.Value)
'Finding out the cost if they need an additional bed.
Dim newcharge As Double = rollawaybed * Val(numberofdays.Text)
If chkbed.Checked = True Then
rollawaybedcharge.Text = Format(newcharge, "currency")
Else
rollawaybedcharge.Text = Format(0, "currency")
End If
'Finding out how much it is going to cost for more than 2 people in the room.
additionalguestcharge.Text = Format(additionalguest, "currency")
'Calculating just how much the room is going to cost with the number of Days staying there.
subtotal.Text = Format(((numberofdays.Text) * (costofroom.Text)), "currency")
'Calculating the total for the room with everything
total = CInt(CInt(subtotal.Text) + CInt(additionalguestcharge.Text) + CInt(rollawaybedcharge.Text))
txttotal.Text = Format(total, "C")
End Sub
' I know this is the long way to write these, but it's easier to follow for beginners...
'This Sub doesn't take any parameters and doesn't return any value to the caller.
Private Sub CalculateBaseCostOfRoom()
If radstandard.Checked = True Then
costofroom.Text = Format(standardrate, "currency")
ElseIf raddeluxe.Checked = True Then
costofroom.Text = Format(deluxerate, "currency")
ElseIf radsuite.Checked = True Then
costofroom.Text = Format(suiterate, "currency")
End If
End Sub
'This Function takes two DateTime objects as parameters. These will come from the Value properties
'of your DateTimePicker controls, dtpArrival and dtpCheckout. This Function will return a Long type
'value representing the number of nights these dates span.
Private Function CalculateDays(ByVal startDate As DateTime, ByVal endDate As DateTime) As Long
Dim numDays As Long
numDays = DateDiff(DateInterval.Day, startDate, endDate) + 1
Return numDays
End Function
'This Function doesn't take any parameters, but will return a Double type value representing the
'additional cost of the room.
Private Function CalculateAdditionalGuests() As Double
Dim additionalguest As Double
If Val(nudguest.Text) > 2 Then
additionalguest = ((Val(nudguest.Text) - 2) * 10) * Val(numberofdays.Text)
Else
additionalguest = 0
End If
Return additionalguest
End Function
RageInTheMachine9532
|
|
|
|
|
ibok23 wrote:
If radstandard.Checked = True Then
costofroom.Text = standardrate
costofroom.Text = Format(standardrate, "currency")
ElseIf raddeluxe.Checked = True Then
costofroom.Text = deluxerate
costofroom.Text = Format(deluxerate, "currency")
ElseIf radsuite.Checked = True Then
costofroom.Text = suiterate
costofroom.Text = Format(suiterate, "currency")
End If
The bolded sections of your code are unnecessary. You're assigning a value to a TextBox then immediately replacing that value with a different one. Your code is full of this pattern. Shorten it up by removing the first assignment, like this:
If radstandard.Checked = True Then
costofroom.Text = Format(standardrate, "currency")
ElseIf raddeluxe.Checked = True Then
costofroom.Text = Format(deluxerate, "currency")
ElseIf radsuite.Checked = True Then
costofroom.Text = Format(suiterate, "currency")
End If
RageInTheMachine9532
|
|
|
|
|
Thanks,
I am suppose to be calling on subs and not have everything underneath the button calculate. I am trying the suggestion up top, but not sure where to copy and paste this section and how to call upon it.
Thank you,
ibok23
|
|
|
|
|
I think I figured it out. I created its own private sub then called for the sub. I wasn't suppose to put it under the btn for that box. My fault.
Thanks for the suggestions and examples - it helps.
Tammy
Thank you,
ibok23
|
|
|
|
|
ya.. i think u were getting the errors from afew posts earlier from the sub that you made with the "_textchanged" at the end of it.. since you never made a sub called exactly "costofrooms", but rather "costofrooms_textchanged". the error occured b/c there was no sub existing that you were tryting to call (costofrooms()), right?
all working now?
------------------------
Jordan.
III
|
|
|
|
|
As far as I know. I am just in the process of commenting on the code itself.
Thank you,
ibok23
|
|
|
|
|
alrighty. hope i was of some assistance.
and remember... CAMEL CASTING.
------------------------
Jordan.
III
|
|
|
|
|
don't worry you were. Thanks.
Tammy
Thank you,
ibok23
|
|
|
|
|
I'm creating an n-tier application that I want to implement decent error handling in. Its probably best to describe an Example and request comment.
The presentation layer is a form to Redeem a coupon. The user enters into the form details and has a submit button.
The business logic layer (Redeem function) will do some basic checking such as the coupon hasnt been validated already or cancelled or expired and if OK will perform the status chnage to indicate that it has now been redeemed.
The data access layer consists of simple getstatus and changestatus functions to call stored procedures.
In this example the data access or business logic layers could fail as a result of a whole host of items - such as SQL problems or invalid status for the action.
If I went with the approach I'm more familar with which is from a VB6 background - I could return different codes from the functions and track in the calling function and control the actions as a result of these different problems. I'd probably set up a enumeration in a interface file used by all components - so that I dont just use magic numbers but that the return code is either success or a code indicating cause of the problem. But I'd still need some exception handling to deal with all other eventuallities.
The more .NET approach may be to create custom exceptions for the application. And throw these errors instead of return codes. This would allow the exceptions to bubble to a layer where they are dealt with. The functions would then return either a success or throw an exception.
Only small simple functions that only require a success or failure would possibly use return code values other than success.
This would require some custom exceptions created for situations like ItemDoesntExist and InvalidStateTransition but I could see this being a nice approach as all functions would have exception handlers and a pretty standard template would be used by deafult on all functions with addition of catch statements for more specifics to be dealt with.
In above example I'd have a different form that would be called if something didn't exist to if the action was invalid because say the status' were incorrect. This is why I'd need specific reasons as to why something had failed.
Any thoughts on these two approaches ? I could use either.....
|
|
|
|
|