|
I've never used the IMAPI2 classes, but from a quick scan of the documentation, you'd have to create an event handler for the IMAPI2.MsftDiscFormat2Data.Update event and wire it up with AddHandler.
|
|
|
|
|
i downloaded a thermometer panel but i cant figure out how to get it into visual basic. there are some files from the download but vb wont open some, what do i do
|
|
|
|
|
Send a message to the developer of the thermometer panel?
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
need some guidance, I have a collection of properties 166 to be spacific, each object in the collection will spawn a thread to perform a long running task, I also want to pump meessages back to the calling thread. threadpool will provide me the solution unfortunatly MS has limited the number of threads to 25 per processor, simple math will tell me that I need a huge box.
so that another approach would be to loop from 0 to max threadpool and spawn an instance of a thread pulling the objectid from the collection based on the threadid. that's fine or the first 50 objects. how would I now pull the remaing objects from the collection.
example
for i as 0 to threadpool.maxthreads -1
dim node as basenode = basecollection(i)
dim rem as new workernode(node)
addhandler rem.messageback new messagehandler(addressof OnMessagesReceived)
rem.dowork
next
assuming dual CPU will make the maxthread value be 50 and my basecollection will hold 166 objects
I am stuck spawning objects 51-165
|
|
|
|
|
With .NET 2.0 SP1, the default was changed from 25 threads per core to 250. This is not to say that using 250 is a good design. Seriously, if you think you need more than 25 threads per core running, you really need to reconsider your design. You'll be wasting so much time in context switching, it's silly.
Also, the ThreadPool throttles it's new thread creation to 2 per second once the thread count exceeds the number of cores running the threads. So, on a single core machine, it'll still take well over a minute to create all of your threads.
Now, having said all that, you can't change the MaxThreadPoolThreads limit in managed code.
|
|
|
|
|
this is good to hear, even though the collection will hold 165 objects, it's unlikly I will actualy spawn all 165 threads at once, each object will represent a pop3 client, that will pop a mailbox return all it's mail perform some formating, auto alerting and store the results in a DB then die. the reason for spawing as many as possible at once is reduce the time between poping, also the reason for passing messages back is for the management interface to watch activity through ipclient....
|
|
|
|
|
Hi All,
After A long time.. Hope u all are good..
I am having btnUpload and btnTransfer. On btnUpload I open a openFileDialogue select any type of file and at transfer i want to transfer it to another location suppose D:\TransferTest\.
But its giving this error Could not find a part of the path 'D:\TransferTest\'.
The code is as below :
Dim filename As String
Dim ofd As OpenFileDialog
Private Sub btnUpload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpload.Click
ofd = New OpenFileDialog()
ofd.Filter = "All Files|*.*"
ofd.ShowDialog()
If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then
filename = ofd.FileName()
txtFile.Text = filename
End If
End Sub
Private Sub btnTransfer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTransfer.Click
File.Copy(filename, "D:\TransferTest\")
End Sub
Help with a code tip... its a urgent..
Regards,
Sourabh
Thanks and Regards,
|
|
|
|
|
Try using the new filesystem namespace:
FileSystem.FileCopy(filename, "D:\TransferTest\")
|
|
|
|
|
Hi,
in Windows you can only create/move/copy files to existing folders, so if either D:\ or D:\TransferTest\ does not exist, you would get such error.
You should use Directory.CreateDirectory() to create a folder (no need to test for existence first!).
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Private Sub btnTransfer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTransfer.Click
if not io.directory.exists("D:\TransferTest\") then
io.directory.createdirectory("D:\Tran.....")
enf if
File.Copy(filename, "D:\TransferTest\")
End Sub
|
|
|
|
|
so far for "no need to test for existence"...
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
First post here so please be patient, I wrote some software for the company that I work for in VB6 for Scheduling and quoting construction based projects and am upgrading to VB 2008, not a problem except for the printing, The user had several check boxes and option groups which related to which pages were printed, each unrelated, the first was a cover page, second page a preamble, third page list of doors etc all taken from different sources, in VB6 it was pretty simple to create a printer object (called myPrint) call the various page sub routines and to put it together example as below:
Select Case True
Case frmPrint.optAll(0).Value = True 'materials listing
MyPrint.NewPage
PProductListingA
Case frmPrint.optAll(1).Value = True 'bill of quantities
MyPrint.NewPage
PBOQsA
Obviously we've lost the NewPage which has been replaced with HasMorePages from with the PrintPage method, I've spent about a week now trying to call the various sub routines from within this and quite simply have hit a brick wall. Lots of examples on the web to point me in the right direction but they all seem to be based around a single block of text printed over various pages, help.
|
|
|
|
|
I cannot help you exactly on your problem, but Microsoft has an excellent article on printing in .NET:
http://msdn.microsoft.com/en-us/magazine/cc188767.aspx[^]
It helped me a lot to learn about printing in VB.NET. Note that there's some source-code relating to the article which also deals with multi-page texts. Maybe it's worth to have look. There is also a lot neat stuff in it, like status texts in status bars, print preview and so on.
|
|
|
|
|
Thanks for the suggestion, unfotunately it still only deals with a multi page single source document as opposed to a different document on mulitple pages.
|
|
|
|
|
I am using a windows forms app vb.net 3.5 SP1 w/VS 2008. I have a DS set up. I have about 4 DateTime Columns in the DS in a particular table that are defined in the SQL2005 server as DateTime NULLable. I've extended the DateTimePicker class to be able to accept a Date? value. The problem is that the DS does not believe that the date columns that are nullable, really are. It always wants to throw an exception. Per someone elses suggestion i set the date fields in the DS designer to DataType "System.Data.SqlTypes.SqlDateTime" with DefaultValue "Null", and AllowDBNull "True", yet the NullValue Property *only* allows "(Throw Exception)" and I think to fix my issue I need it to be "Null" however if I do that, the compiler says "Null is not a valid AllXsd value", which is where I'm stuck and I'm afraid is a little beyond my understanding... are there any suggestions you could make to me? I'd really appreciate it!! Thanks in advance.
|
|
|
|
|
try setting it to DBNull.Value That is the equiv. of a null in the db, "Null" is not.
|
|
|
|
|
Thanks for the reply Troy...Just tried your suggestion and the same thing happens. The actal error it gives is:
Error 44 Custom tool error: Failed to generate code. Failed to generate code. Exception has been thrown by the target of an invocation. The string 'DBNull.Value' is not a valid AllXsd value. Exception has been thrown by the target of an invocation. The string 'DBNull.Value' is not a valid AllXsd value. C:\Users\kkomar\Documents\Visual Studio 2008\Projects\Idaho AGC DataCenter\Idaho AGC DataCenter\Forms\OrganizationsFrmDataSet.xsd 1 1 Idaho AGC DataCenter
...As soon as i plug that value in.
|
|
|
|
|
personaly me I am not a fan or leaving vales null, most controls like the dataset will through a null exception, that said what I prefer to do is when filling the dataset with defaults on null
<br />
din ds as datarow = mydataset.mydatatable.newrow<br />
ds("MyDateColumn") = IIf(IsDbNull(MyDbColumn),"01/01/1900",MyDbColumn)<br />
mydataset.mydatatable.rows.add(ds)<br />
|
|
|
|
|
I appreciate the suggestion, however, I don't bind each column individually like that.
I just fill the DS and I use the designer to bind all the controls to the binding source columns.
Does this mean I'll have to manually code all the 80 column bindings on my form?
|
|
|
|
|
you can still use the designer to bind your controls to the dataset, but I personaly would use an nTier approach and create a class to fill the dataset.
From the top of my head it will go something like this, but you may want to google sqlconnection and sqlcommand on the proper implementation
public class mydataleyer
public function FillDataset() as mydataset
dim results as new mydataset
dim con as new sqlconnection("server","database","username","password")
dim qry as new sqlcommand("select * from mytable")
con.open
dim rdr as datareader = qry.executereader(cn)
while rdr.read()
dim rw as datarow = results.tables(0).newrow
rw("datecolumn") = IIF(IsDBNull(rdr(0)),"01/01/1900",rdr(0))
results.tables(0).rows.add(rw)
end while
return results
end function
end class
from you form onload event
private sub myform_load(byval sender as object,byval e as eventargs) handles mybase.load
dim ldr as new mydatalayer
me.dataset1 = ldr.FillDataset
end sub
|
|
|
|
|
Aha, so will doing:
rw("datecolumn") = IIF(IsDBNull(rdr(0)),"01/01/1900",rdr(0))
make it so that anytime that column is accessed, it will filter out the DBNull, or just for the initial loading? The reason I ask is because the date columns i have are to be re-nullable, even if they're given a value; the value has to be able to go back to null in the actual database at some point...
|
|
|
|
|
when you write values to the database you can simply reverse the logic IIF(ds("Datacolumn") = "01/01/1900",nothing,ds("datacolumn")
|
|
|
|
|
OK, for those poor unfortunate souls who are having this same problem as me, here are the steps I've done so far to remedy:
1) Use the nulldatetimepicker extension shown here: http://www.codeproject.com/KB/selection/NullableDateTimePicker.aspx[^]
and if you're using VB, convert it with this: http://www.developerfusion.com/tools/convert/csharp-to-vb/[^]
2) open the .xsd file of your dataset and manually change the msprop:nullValue="_throw" property of any datetime field to msprop:nullValue="_null". Be aware: every so often the designer will decide to just omit the datetime fields because it's caught on to your treacherous workaround of Microsoft's poor design; and that just cannot be allowed. :P If that happens just go to the designer again and set the fields as (throw exception), save, close, and follow this step again.
This seems to work just fine for existing records. You can re-null datetime fields and successfully update. The only thing I'm having trouble with is inserting new records. I always get:
{"Failed to convert parameter value from a Int32 to a DateTime."}
{"Invalid cast from 'Int32' to 'DateTime'."}
...which is baffling me, but I'm still trying to research, debug, reinvent the wheel for. I'll keep posting as I figure it out.
Here is my entire "add record" sub:
Private Sub AddBranchToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddBranchToolStripButton.Click
If PermissionsMode = "ReadWrite" Then
Dim MainID As String = "0"
Dim OrgName As String = "Error"
'Set the OrgRowIsAdding flag to true so that the AutoSave feature doesnt try to save a row with blank data
OrgRowIsAdding = True
'record the main loc ID and org name
MainID = ParentOrgIDTextBox.Text
OrgName = OrganizationTextBox.Text
'Actually add the branch
Try
If Me.OrganizationsBindingSource.AddNew() IsNot Nothing Then
OrganizationTextBox.Text = OrgName
ParentOrgIDTextBox.Text = MainID
MemberStatusComboBox.SelectedValue = "Branch"
MemberTypeComboBox.SelectedValue = "Branch"
Me.Text = "[Branch] " & OrgName
OrgRowIsAdding = False
SetFormControls(True, True)
Else
MsgBox(My.Settings.OrganizationsFrmAddRecGenErrorMsg, MsgBoxStyle.Exclamation, "Error Adding Record")
GoTo skipaddbranch
End If
Catch ex As Exception
Throw New Exception("Branch Location Add Failed", ex)
GoTo skipaddbranch
End Try
Else
MsgBox(My.Settings.StdDenyWriteError, MsgBoxStyle.Exclamation, "Access Denied")
GoTo skipaddbranch
End If
skipaddbranch:
OrgRowIsAdding = False
Exit Sub
End Sub
/rant_at_microsoft
Am I just crazy or is it too much to ask of Microsoft to support the SQL datatype in full in their own development application? They wrote SQL 2005, and they wrote Visual Studio 2008.
This problem is driving me nuts. Yeah i know, i know...most people claim it has something to do with SQL/Visual Studio versions not being exactly on par, but really I've found posts on this same topic concerning VS 2005!!! So personally, I don't buy it. Additionally, you've been able to null datetime fields in SQL for a while now, so to me this is just plain old negligence on Microsoft's part. Get it together Microsoft!
/endrant
/rant_at_everyone
Am I to understand that every single programmer that uses Visual Studio simply accepts the workaround to use date.mindate as a replacement for null???? I guess I just can't accept that. I'm determined to figure this out.
/endrant_at_everyone
More to come....
|
|
|
|
|
Update:
Still nothing. I've even set my code to set any Null date to 1/1/1900 even though I really didnt want to do that. When I add a new record, no matter what, when i try to save back to the DB, I always get:
"Invalid cast from 'Int32' to 'DateTime'."
It shows the exception originates in the automatically generated "UpdateAll" Sub created by the dataset designer. Here is the code just before where the exception occurs:
Try
'---- Prepare for update -----------
'
If (Not (Me._employeesTableAdapter) Is Nothing) Then
revertConnections.Add(Me._employeesTableAdapter, Me._employeesTableAdapter.Connection)
Me._employeesTableAdapter.Connection = CType(workConnection,Global.System.Data.SqlClient.SqlConnection)
Me._employeesTableAdapter.Transaction = CType(workTransaction,Global.System.Data.SqlClient.SqlTransaction)
If Me._employeesTableAdapter.Adapter.AcceptChangesDuringUpdate Then
Me._employeesTableAdapter.Adapter.AcceptChangesDuringUpdate = false
adaptersWithAcceptChangesDuringUpdate.Add(Me._employeesTableAdapter.Adapter)
End If
End If
If (Not (Me._organizationMemosTableAdapter) Is Nothing) Then
revertConnections.Add(Me._organizationMemosTableAdapter, Me._organizationMemosTableAdapter.Connection)
Me._organizationMemosTableAdapter.Connection = CType(workConnection,Global.System.Data.SqlClient.SqlConnection)
Me._organizationMemosTableAdapter.Transaction = CType(workTransaction,Global.System.Data.SqlClient.SqlTransaction)
If Me._organizationMemosTableAdapter.Adapter.AcceptChangesDuringUpdate Then
Me._organizationMemosTableAdapter.Adapter.AcceptChangesDuringUpdate = false
adaptersWithAcceptChangesDuringUpdate.Add(Me._organizationMemosTableAdapter.Adapter)
End If
End If
If (Not (Me._peopleTableAdapter) Is Nothing) Then
revertConnections.Add(Me._peopleTableAdapter, Me._peopleTableAdapter.Connection)
Me._peopleTableAdapter.Connection = CType(workConnection,Global.System.Data.SqlClient.SqlConnection)
Me._peopleTableAdapter.Transaction = CType(workTransaction,Global.System.Data.SqlClient.SqlTransaction)
If Me._peopleTableAdapter.Adapter.AcceptChangesDuringUpdate Then
Me._peopleTableAdapter.Adapter.AcceptChangesDuringUpdate = false
adaptersWithAcceptChangesDuringUpdate.Add(Me._peopleTableAdapter.Adapter)
End If
End If
If (Not (Me._organizationsTableAdapter) Is Nothing) Then
revertConnections.Add(Me._organizationsTableAdapter, Me._organizationsTableAdapter.Connection)
Me._organizationsTableAdapter.Connection = CType(workConnection,Global.System.Data.SqlClient.SqlConnection)
Me._organizationsTableAdapter.Transaction = CType(workTransaction,Global.System.Data.SqlClient.SqlTransaction)
If Me._organizationsTableAdapter.Adapter.AcceptChangesDuringUpdate Then
Me._organizationsTableAdapter.Adapter.AcceptChangesDuringUpdate = false
adaptersWithAcceptChangesDuringUpdate.Add(Me._organizationsTableAdapter.Adapter)
End If
End If
If (Not (Me._cSISelections2004TableAdapter) Is Nothing) Then
revertConnections.Add(Me._cSISelections2004TableAdapter, Me._cSISelections2004TableAdapter.Connection)
Me._cSISelections2004TableAdapter.Connection = CType(workConnection,Global.System.Data.SqlClient.SqlConnection)
Me._cSISelections2004TableAdapter.Transaction = CType(workTransaction,Global.System.Data.SqlClient.SqlTransaction)
If Me._cSISelections2004TableAdapter.Adapter.AcceptChangesDuringUpdate Then
Me._cSISelections2004TableAdapter.Adapter.AcceptChangesDuringUpdate = false
adaptersWithAcceptChangesDuringUpdate.Add(Me._cSISelections2004TableAdapter.Adapter)
End If
End If
'
'---- Perform updates -----------
'
If (Me.UpdateOrder = UpdateOrderOption.UpdateInsertDelete) Then
result = (result + Me.UpdateUpdatedRows(dataSet, allChangedRows, allAddedRows))
result = (result + Me.UpdateInsertedRows(dataSet, allAddedRows))
Else
result = (result + Me.UpdateInsertedRows(dataSet, allAddedRows))
result = (result + Me.UpdateUpdatedRows(dataSet, allChangedRows, allAddedRows))
End If
result = (result + Me.UpdateDeletedRows(dataSet, allChangedRows))
'
'---- Commit updates -----------
'
workTransaction.Commit
If (0 < allAddedRows.Count) Then
Dim rows((allAddedRows.Count) - 1) As Global.System.Data.DataRow
allAddedRows.CopyTo(rows)
Dim i As Integer = 0
Do While (i < rows.Length)
Dim row As Global.System.Data.DataRow = rows(i)
row.AcceptChanges
i = (i + 1)
Loop
End If
If (0 < allChangedRows.Count) Then
Dim rows((allChangedRows.Count) - 1) As Global.System.Data.DataRow
allChangedRows.CopyTo(rows)
Dim i As Integer = 0
Do While (i < rows.Length)
Dim row As Global.System.Data.DataRow = rows(i)
row.AcceptChanges
i = (i + 1)
Loop
End If
Catch ex As Global.System.Exception
workTransaction.Rollback
'---- Restore the dataset -----------
If Me.BackupDataSetBeforeUpdate Then
Global.System.Diagnostics.Debug.Assert((Not (backupDataSet) Is Nothing))
dataSet.Clear
dataSet.Merge(backupDataSet)
Else
If (0 < allAddedRows.Count) Then
Dim rows((allAddedRows.Count) - 1) As Global.System.Data.DataRow
allAddedRows.CopyTo(rows)
Dim i As Integer = 0
Do While (i < rows.Length)
Dim row As Global.System.Data.DataRow = rows(i)
row.AcceptChanges
row.SetAdded
i = (i + 1)
Loop
End If
End If
Throw ex
Finally
That "ex" exception is thrown and I get the error above. There are no Int32's being cast to datetime. all int32's are int32's and all datetime's are datetime's...what in the heck is happening?
|
|
|
|
|
Final Update:
Microsoft, you've won. I've been beaten into submission. Despite countless forum posts, weeks of web research, and direct queries to MS employees with no solid answer, I've succumbed to the workaround.
Here's what to do:
1) Follow my original instructions to use the nullabledatetimepicker. modify it to accept 1/1/1900 as it's "null" value, so it shows the null string but reports it's value as 1/1/1900.
2) change your DB schema so that all dates are NOT nullable. Set the default value to 1/1/1900 12:00:00 AM, or getdate(), depending on what you're doing with it. You'll also need to do an update query for all NULL dates to set to '1/1/1900 12:00:00 AM'.
3) match the DS to the DB schema.
4) adjust any code in your program to understand the 1/1/1900 value as actually "null".
5) Be over and done with it and get on with your life!
I hate workarounds. Maybe Visual Studio 2010 won't be such a compromised program...we shall see.
|
|
|
|
|