|
Hello,I have the following project and I have tried and tried but can't seem to get it. Can anyone help?
I have to write a program to campare the secant method with newton's method for finding the roots of each function:
x^3 - 3x + 1 with starting point Xo=2
x^3 - 2 sin x with starting point Xo=.5
The instructions also state to use the X1 value from Newton's method as the second starting point for the secant method and to print out each iteration for both methods. I appreciate any help.
|
|
|
|
|
L_JIMENEZ wrote:
I have tried and tried
What have you tried ? Where are you having trouble ?
L_JIMENEZ wrote:
I appreciate any help.
Sure, but no-one is going to do your homework for you. If you can post what you've got, and where you're stuck, we're all glad to help out.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
the purpose of this code is to display data in specific textboxes when a user click on any items in listbox ... this one i'm coding for web application.
but actually, it doesn't work at all ... i could not figure out the problems ...
could anyone there help me please?
thanks in advance
Private Sub activateform()
Dim mlstoneDreader As OleDb.OleDbDataReader
Dim mlstoneCommand As OleDb.OleDbCommand
Dim slect As String
Dim StSQl As String
Dim ConnStr As String
ConnStr = BuildSQLConnection()
slect = lstmilestone.SelectedItem.Value
StSQl = "Select staffId, LastName, FirstName, Email "
StSQl &= " From Staff "
StSQl &= " where staffId = " & slect
Try
mlstoneCommand = New OleDb.OleDbCommand()
With mlstoneCommand
.Connection = New OleDb.OleDbConnection(ConnStr)
.Connection.Open()
.CommandText = StSQl
mlstoneDreader = .ExecuteReader(CommandBehavior.SingleRow)
End With
If mlstoneDreader.Read() Then
With mlstoneDreader
txtid.Text = .Item("StaffId").ToString()
txtmlname.Text = .Item("LastName").ToString()
txtdesc.Text = .Item("FirstName").ToString()
End With
Else
ClearAll()
End If
mlstoneDreader.Close()
mlstoneCommand.Connection.Close()
Catch mlstone_e As Exception
MsgBox("Connection failed")
End Try
End Sub
Private Sub ClearAll()
txtid.Text = " "
txtmlname.Text = " "
txtdesc.Text = " "
txtnoofday.Text = " "
End Sub
|
|
|
|
|
Fired Dragon wrote:
but actually, it doesn't work at all ... i could not figure out the problems ...
Why not ? i.e. what doesn't it do ? Have you traced through to see what is going into your SQL ? Run your SQL in query analyser to make sure it should return the values you expect ? etc.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
hi christ
although, data displays in a listbox, when i select items in the listbox, it doesn't display in the textboxes.
i've ran my sql in query analyser, the results show out correctly.
could you help me to solve out please?
|
|
|
|
|
You say it's a web application - when you click on an item in the listbox, does it postback ? Have you put breakpoints in to verify that your code is being called ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Public Class milestone
Inherits System.Web.UI.Page
Protected WithEvents btnadd As System.Web.UI.WebControls.Button
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents btnmodify As System.Web.UI.WebControls.Button
Protected WithEvents Btndelete As System.Web.UI.WebControls.Button
Protected WithEvents txtmlname As System.Web.UI.WebControls.TextBox
Protected WithEvents txtnoofday As System.Web.UI.WebControls.TextBox
Protected WithEvents lstmilestone As System.Web.UI.WebControls.ListBox
Protected WithEvents txtid As System.Web.UI.WebControls.TextBox
Protected WithEvents txtdesc As System.Web.UI.WebControls.TextBox
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
InitializeComponent()
Listmilestone()
'Put user code to initialize the page here
End Sub
Private Function Listmilestone()
Dim mlstoneDreader As OleDb.OleDbDataReader
Dim mlstoneCommand As OleDb.OleDbCommand
Dim slect As Web.UI.WebControls.ListBox
Dim StSQl As String
Dim ConnStr As String
ConnStr = BuildSQLConnection()
StSQl = " Select staffId, FirstName "
StSQl &= " From staff"
mlstoneCommand = New OleDb.OleDbCommand()
With mlstoneCommand
.Connection = New OleDb.OleDbConnection(ConnStr)
.Connection.Open()
.CommandText = StSQl
mlstoneDreader = .ExecuteReader(CommandBehavior.SequentialAccess)
End With
lstmilestone.Items.Clear()
Do While mlstoneDreader.Read()
lstmilestone.Items.Add(mlstoneDreader.Item("Firstname"))
Loop
mlstoneDreader.Close()
If lstmilestone.Items.Count > 0 Then
lstmilestone.SelectedIndex = 0
End If
mlstoneDreader.Close()
mlstoneCommand.Connection.Close()
End Function
Private Sub lstmilestone_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstmilestone.SelectedIndexChanged
activateform()
End Sub
Private Sub activateform()
Dim mlstoneDreader As OleDb.OleDbDataReader
Dim mlstoneCommand As OleDb.OleDbCommand
Dim slect As String
Dim StSQl As String
Dim ConnStr As String
ConnStr = BuildSQLConnection()
slect = lstmilestone.SelectedItem.Value
StSQl = "Select staffId, LastName, FirstName, Email "
StSQl &= " From Staff "
StSQl &= " where staffId = " & slect
Try
mlstoneCommand = New OleDb.OleDbCommand()
With mlstoneCommand
.Connection = New OleDb.OleDbConnection(ConnStr)
.Connection.Open()
.CommandText = StSQl
mlstoneDreader = .ExecuteReader(CommandBehavior.SingleRow)
End With
If mlstoneDreader.Read() Then
With mlstoneDreader
txtid.Text = .Item("StaffId").ToString()
txtmlname.Text = .Item("LastName").ToString()
txtdesc.Text = .Item("FirstName").ToString()
End With
Else
ClearAll()
End If
mlstoneDreader.Close()
mlstoneCommand.Connection.Close()
Catch mlstone_e As Exception
MsgBox("Connection failed")
End Try
End Sub
Private Sub ClearAll()
txtid.Text = " "
txtmlname.Text = " "
txtdesc.Text = " "
txtnoofday.Text = " "
End Sub
Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click
milestoneAdd()
End Sub
Private Sub milestoneAdd()
Dim stSQL As String
Dim mlstoneCommand As OleDb.OleDbCommand
Dim milestone_Rows As Integer
Dim SQLConn As New Clsconnection()
stSQL = "INSERT INTO ProjectMilestone "
stSQL &= " Id, "
stSQL &= " Description, "
Try
mlstoneCommand = New OleDb.OleDbCommand()
With mlstoneCommand
.Connection = New OleDb.OleDbConnection(BuildSQLConnection())
.Connection.Open()
.CommandText = stSQL
milestone_Rows = .ExecuteNonQuery()
If milestone_Rows <> 1 Then
MsgBox("Did not insert row")
End If
.Connection.Close()
End With
Catch oException As Exception
MsgBox(oException.Message)
End Try
End Sub
Private Function BuildSQLConnection() As String
Dim ConnStr As String
ConnStr = "Provider=sqloledb"
ConnStr &= ";Data Source=(local)"
ConnStr &= ";Initial Catalog=PROMAN"
ConnStr &= ";User ID=sa"
ConnStr &= ";Password=hien"
Return ConnStr
End Function
End Class
|
|
|
|
|
I'd prefer if you answered my question - does the page postback ? Does your event handler get called ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
no, it doesnt, when i click on an item in the listbox, it doesnot postback anything to the textboxes,
Does your event handler get called ? yeah, it does
|
|
|
|
|
Fired Dragon wrote:
no, it doesnt, when i click on an item in the listbox, it doesnot postback anything to the textboxes,
Postback is what we ASP.NET developers call it when the page posts back to the server. If your event is being called, postback is occuring.
You obviously haven't stepped through the code. Your code looks like this:
Private Sub lstmilestone_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstmilestone.SelectedIndexChanged<br />
activateform()<br />
End Sub
Now, why would this event handler do a jolly thing, when there's no code in it ? The code in activate form needs to be moved into the event handler.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
i've moved the code in "activateform" into "lstmilestone_SelectedIndexChanged" but unfortunately, it doesnot work as i planed
Christ, i appreciate for what you've help me honestly.
|
|
|
|
|
I need more info than 'it doesn't work as I planned'. Have you stepped through the code ? Have you checked what the SQL you're generating looks like ? Is the SQL OK ? What result are you getting ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
i have steped through the code, i've used 'step into' but it's jumped to Exception in the event handler 'lstmilestone_SelectedIndexChanged'
my SQL is ok, it shows out staffID, lastname, firstnam, email ... etc
i've already tried to find the problems for a week. it's really stressful
|
|
|
|
|
Fired Dragon wrote:
it's jumped to Exception in the event handler 'lstmilestone_SelectedIndexChanged'
Where in the event handler, exactly ?
Fired Dragon wrote:
my SQL is ok, it shows out staffID, lastname, firstnam, email ... etc
I'm talking about the SQL that's generated by the event handler. Have you checked that ? Does it get that far ?
slect = lstmilestone.SelectedItem.Value
for starters you should check if SelectedItem is null before attempting this.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
If mlstoneDreader.Read() Then
With mlstoneDreader
txtid.Text = .Item("StaffId").ToString()
txtmlname.Text = .Item("LastName").ToString()
txtdesc.Text = .Item("FirstName").ToString()
End With
Else
ClearAll()
End If
mlstoneDreader.Close()
mlstoneCommand.Connection.Close()
'step into jumping to
Catch mlstone_e As Exception
MsgBox(mlstone_e.Message)
End Try
my sql doesnt get any problems here, Christ. and i've watched variable 'slect', it has had value inside,
|
|
|
|
|
What is the error message you are getting ?
Have you checked the state of the reader ( that is, is it set up with a valid connection, etc. )
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Fired Dragon wrote:
this is all what i have done, it may make you more visible
yes i am now more visible than before, thanks i hadn't seen my left arm for years
|
|
|
|
|
Anonymous wrote:
thanks i hadn't seen my left arm for years
Arthur, there's an infinite number of monkeys here that want to talk to us about this script for Hamlet they've worked out.
Do you want to know more?
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
Hi,
I've got a windows service that connect to a database. all is working except when I restart the computer 'cause my service start before SQL Server.
So my question is : how can I do to make my service dependent of MS-SQL ?
I want it to run only when MS-SQL is running.
Thx
Sybux
|
|
|
|
|
If your service is going to be deployed to another server WITHOUT an SQL server, it's best if your service is not dependent on the start of the SQL server. Rather, it should just throw appropriate exceptions back to the caller when appropriate. Just because the SQL server is running doesn't mean that the database will be available.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I would like to add a running time in a text box or label and I am not sure how to go about it. I was thinking of creating a timer function that reloads the textbox with the time every one second. Would that be too much for the app while the user is doing other things in the app? Is there another way?
Also, I would need to display the current running time from other time zones depending on the state the user is working with. Any ideas?
Thanks
|
|
|
|
|
A simple Timer will do the trick. Just set its .Interval property to 1000 for every 1 second. Then just fill in the current time in the TextBox.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello
Please tell me how to create an instance of a class in an ActiveX Dll, when runtime in VB.NET
In VB6 I simply used
Set obj = CreateObject(ServerName.ClassName)
to create an instance of class ClassName.
But I couldn't find such CreateObject function in VB.NET
Please help me. I do need to access these classes at runtime.
Thanks in advance.
|
|
|
|
|
Make sure you include this line at the top of your code:
Imports Microsoft.VisualBasic
Then you can use the CreateObject function to create a COM registered object. Docs on CreateObject can be found here[^] on MSDN.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks Dave!
Yes I had forgot to import Microsoft.VisualBasic !!!
|
|
|
|