|
Great help ... I missed that one
|
|
|
|
|
I have a formula that returns a value as single. In the case that it returns something like 9.3416666666666666666666666666667, I need to use 9.34166 (5 places of precision without rounding). When using Math.Round or Format("#.#####"), the last digit is being rounded to 7 (9.34167).
Is there an easy way to accomplish this?
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
I have a corny method of making the result a string, doing string comp. of where the decimal place to return the correct thing and recasting backing into a single.
Seems like a cheesy way to do it though
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
You'd have to write your own little function to do that. You'd raise 10 to the number of decimal places you need, call it multiplier, then multiply the value in question by this multiplier, truncate the value to an integer, then divide the result by the multiplier.
Private Function RoundOff(ByVal num As Double, ByVal decimalPlaces As Integer) As Double
Dim multiplier As Double = Math.Pow(10, decimalPlaces)
Dim result As Double = Math.Truncate(num * multiplier) / multiplier
Return result
End Function
|
|
|
|
|
Brilliant!
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Dave, I beleive that credit should be given where it is due.
You have helped me yesterday, and I see you do give of yourself a lot on here, so may I just say thanks.
------------------------------------
"I am always serious about what I do, not necessarily about how I do it."
Tom Baker
|
|
|
|
|
Can I do it with the SQLdataadapter?
I've tried this code -
Dim adapterGIS As SqlDataAdapter = New SqlDataAdapter( _
queryString, connectionGIS)
Dim tblCRW_GIS_Data As DataTable
tblCRW_GIS_Data = dsCRW.Tables("CRW_GIS_Data")
adapterGIS.UpdateCommand = New SqlCommand("ALTER TABLE CRW_GIS_Data ADD (reception1 string(7)", connectionGIS)
adapterGIS.Update(tblCRW_GIS_Data)
without success. No errors, but no new column either.
Thanks
|
|
|
|
|
You can do something like this:
Using SqlConn As New SqlConnection(ConnectString), cmd As New SqlCommand("ALTER TABLE [dbo].[Setup] ADD [TestCol] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL", SqlConn)
SqlConn.Open()
cmd.ExecuteNonQuery()
'populate your datatable after the column change
SqlConn.Close()
End Using
Take your raw sql statement (meaning: "ALTER TABLE CRW_GIS_Data ADD (reception1 string(7)") and run in it SQL first and fix the errors. String (use CHAR, VARCHAR, etc) is not supported in SQL.
Cheers!
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Thanks that looks like it.
Something odd though.... The query checks out in management studio 08 (SQL).
I let it run for 20 minutes and it was still executing. I killed it. Seems an awful long time to add one column. The table only has 30,000 records in it
|
|
|
|
|
Got it. An application from the previous day had been orphaned and had the table locked. Thanks again.
|
|
|
|
|
I have 2 collection objects in a LogRequest class. One is a dictionary(string, myStruct) and the other is a list(of String). In a continuous thread, I am updating the myStruct data in m_dict and possibly adding items to m_List, depending on what type of data it is.
I also have a tcp listener that accepts client requests for this data. I make the data available through 2 different properties; Data, which gets the m_dict data and StateData, which gets the list data.
Currently I am using the SyncLock in the thread during the update and when the data is retrieved for the m_dict but I am not sure what to do with locking the list. Do I use a separate lock obj or is it already locked bc it was locked at the beginning of the update? Would using the same lock obj in both retrieving routines cause a deadlock?
Public Class LogRequest
While loop
SyncLock lock_obj
For i = 0 to x (however many myStructs need to be updated in m_dict)
Dim data as myStruct= m_dict.Item(name)
data.Value = 'new value'
data.Time = 'new time'
if data.IsState then
m_List.Add("")
End if
m_dict(name) = date
Next
End While
Public ReadOnly Property Data() as string
Get SyncLock lock_obj
For each kvp as KeyValuePair(of String, myStruct) in m_dict
...builds output string
Next
Return string to client
End get
End Property
Public ReadOnly Property StateData() as string
Get
SyncLock ?? 'I dont know what to lock here
For each s as string in m_List
....builds output string
Next
Return string ot client
End SyncLock
End Get
End Property
modified on Thursday, April 9, 2009 11:00 AM
|
|
|
|
|
It doesn't look like there's a foreign key relationship between the two lists that has to be maintained, so you would probably use two lock objects, one for each list.
|
|
|
|
|
Dave, Thanks for responding...
What do mean by "foreign key relationships"
so basically I can do a lock inside of a lock
SyncLock for the dictionary
for loop through the dictionary
synclock for the list
update the list
end synclock
next
end synclock
then use the corresponding synclocks in each property
(I thought that doing this would somehow cause a deadlock)
|
|
|
|
|
This would work and not result in a deadlock. Keep in mind that the dictionary would not be readable by outside threads until the entire for loop was finished though. If this is an issue, you can move the synclock inside the loop around the update for the dictionary, freeing the object for reads by other threads until an update actually needs to be made to the dictionary.
By "foreign key rel", I mean that the data in one list does not depend on data existing in the other and being managed as a single unit.
|
|
|
|
|
The data that gets put into m_list comes from the structure that was just read from m_dict.
ex.
If data.IsState then
m_list.Add('new value', 'new time', data.ID, data.GetTextValue)
End if
where GetTextValue is a function that gets a corresponding text string to the data value
Dave Kreskowiak wrote: Keep in mind that the dictionary would not be readable by outside threads until the entire for loop was finished though.
I was aware of that and thought moving the SyncLock around just the m_dict = data line but I thought that reading it
data = m_dict(name)
would also need the lock and figured just to put it around the whole thing
modified on Thursday, April 9, 2009 2:47 PM
|
|
|
|
|
Is it possible to send arguments to a click once app? I can start a click once app programatically, but am unable to send the app any arguments.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
|
Zing!!! Dave w/ the seal clubbing. Ok, I was remiss in explaining my question in more details; I did offend the gods and already attempted Google.
I have a WinApp that is being published into a network share (on my local box). Obviously network shares are not supported from the command line, therefore the URL style passing doesn't work.
So, from the command line with a local directory or network share (files are not hosted on a web server or via web page), is it possible to pass args to a click once app?
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Jon_Boy wrote: Obviously network shares are not supported from the command line,
What do you mean?? Are you saying that you can't launch an .EXE from the command line when the .EXE resides in a share. Of course you can, so long as the machine trusts the network location. By default, .NET will not run code from a non-local source.
I guess I'm not completely understanding your environment or your app's setup.
|
|
|
|
|
Ok, I'll try more examples here...
For ClickOnce deployment, lets say you want to test the network publishing functionality (not the web site deployment). You need to create a directory to push the published files to and then that directory needs to be shared. For example: create directory C:\DeployTesting and give it a public share of \\WorkstationName\DeployTesting.
ClickOnce can then deploy the each published version successfully. You will be able to run the app fine and pick up updates from the start menu program link. Everything to this point is fine.
I can manually start the app from the command line using the "C:\Documents and Settings\User\Start Menu\Programs\Company\DeployTesting\App1.appref-ms".
Unless I am mistaken, you can't start the app via the UNC path, because you can't access the network share name from the command line (IE: \\Workstatuion1\DeployTesting\App1.application). From what I can gather, the arg passing is only supported via the web since they are passed in the URL path.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Jon_Boy wrote: Unless I am mistaken, you can't start the app via the UNC path, because you can't access the network share name from the command line
Try the CreateProces API, I think that DOS just doesn't like the UNC-path. You could also try mapping your path to a drive-letter
I are troll
|
|
|
|
|
Eddy Vluggen wrote: Try the CreateProces API, I think that DOS just doesn't like the UNC-path. You could also try mapping your path to a drive-letter Smile
Tru-dat! Process can be started, but can't pass args like this: "http://clickonce.thing.com/shell.application?p1=this&p2=that"
I've tried diff. combos of passing in args like ?this, ?p1=this, this, etc - no go.
Sigh.
Maybe the next version of VS will have better support on the ClickOnce stuff (regarding passing args and allowing for single file updating, etc).
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Are you trying to launch it local, or through a webbrowser? I was under the assumption that you are trying to run an executable located on the path "\\Workstatuion1\DeployTesting\App1.application".
The way you're putting it now makes wonder whether you are trying to pass arguments to the installer-application?
I are troll
|
|
|
|
|
Eddy Vluggen wrote: Are you trying to launch it local, or through a webbrowser? I was under the assumption that you are trying to run an executable located on the path "\\Workstatuion1\DeployTesting\App1.application".
Yes - networkable paths, but clickonce allows for passing arguments via a URL only (at least through my research).
The setting for passing args is called "Allow URL parameters to be passed to application". All the examples I have found reflect that.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
I didn't know that, just bookmarked the thread as a future reference
I is learning
|
|
|
|