|
Well, this code doesn't have anything to do with SQL.
This only applies to VB.NET 2005 (.NET Framework 2.0) and above! It will NOT work with the .NET Framework 1.1 and below!
But, Date, which is just an alias for the DateTime type, normally cannot be Nothing, or null in C#. You'd have to declare it a special way to get it to work.
Dim myDate As New Nullable(Of DateTime)
myDate = New Date(2007, 7, 7)
If myDate.HasValue Then
' whatever you want if there is a value
Else
' myDate is Nothing, so...
End If
|
|
|
|
|
Hi,
Thanks a lot for the reply!
I've actually tried the As New Nullable(Of DateTime) code before, but there's a problem with that in other parts of my code. One part is where I use a '+' symbol it says "Operator '+' is not defined for types 'System.Nullable(Of Date)'" and it also causes an error on my SQL insert statement which is "Operator '&' is not defined for types 'String' and 'System.Nullable(Of Date)'."
I'm fairly new to VB.NET, SQL, and ASP.NET but those things seem to be almost totally unrelated as far as a nullable variable goes, guess not.
Oh, and just to let you know, I am using the .NET 2.0 framework.
Thanks again for the reply,
aqzman
|
|
|
|
|
aqzman_ wrote: I've actually tried the As New Nullable(Of DateTime) code before, but there's a problem with that in other parts of my code. One part is where I use a '+' symbol it says "Operator '+' is not defined for types 'System.Nullable(Of Date)'" and it also causes an error on my SQL insert statement which is "Operator '&' is not defined for types 'String' and 'System.Nullable(Of Date)'."
That's because you have to get the value out of the Nullable type before you can use it.
Dim myDate As Nullable(Of DateTime)
myDate = New Date(2007, 7, 7)
' myDate.Value returns a Date object, IF there is a value...
If myDate.HasValue Then
Debug.WriteLine("DATE: " & myDate.Value.ToShortDateString())
Else
Debug.WriteLine("DATE: Nothing")
End If
-- modified at 13:46 Monday 16th July, 2007
|
|
|
|
|
Thanks a lot for your help! I really appreciate it.
|
|
|
|
|
I am having a hard time finding good articles that show me how to do the following. I currently have data from a database table on my pc loaded in a dataset. I am currently binding that data to a datagrid. But, I want to be able to use dataviews so I can filter the data from the dataset. I have found nothing that gives you a step by step example of this. They only references DataTables, or how to create dataviews. Not how to create dataviews using datasets. Can anyone point me in the right direction.
|
|
|
|
|
I know this is a silly question, but have you looked around here?
I am not sure if this is one you might need, but it looks like you can pull info from it: http://www.codeproject.com/dotnet/filterdialog.asp[^]
"I've seen more information on a frickin' sticky note!" - Dave Kreskowiak
|
|
|
|
|
|
Cool deal. Good luck with them
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
I need this to update a progress bar.First a DOS service is run in the background , which writes a log file as it runs , the percentage info can be retrieved (there is no other way to get the percentage since this is a dos service) from the log file,but i get an error that the file is being used by another process(the DOS one).Its pointless to get info from the log file after the DOS process completes,as i need it to update a progress bar.Is there any solution to this?
Thanks in Advance,
Regards,
Vivek
|
|
|
|
|
Hi,
two attempts:
1.
I think the following code works even when the file is still open (and being written to)
by another process:
FileInfo fi=new FileInfo(filename);
log("size="+fi.Length);
2.
there is a solution if the other process has created the file with a share mode of
read or readwrite, meaning it allows other processes to simultaneously read or readwrite
the same file.
If it did, you now can open the same file with FileMode.Read and FileShare.ReadWrite
(i.e. "I want to read" and "I allow others to read and write").
And one remark:
files get buffered, the buffer gets written to disk for sure only when one closes the
file, or performs a flush operation (forcing the physical write). So for small files
that dont flush, watching the size might not be a good progress indication.
|
|
|
|
|
Thanks a lot for giving the idea of using the file's length.
Vivek
|
|
|
|
|
If the other process opens and writes to it's file, denying shared read, there's nothing you can do. If it allows shared read by other applications while it's writing, then you can open the file using:
Dim fs As New FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
|
|
|
|
|
I'm struggling to work out how to iterate through treenodes. What I've done is programmatically created a TreeView, creating a (DatabaseName) header as follows:
trvDbNameNormal = Me.TreeView1.Nodes.Add("DatabaseName", "Common tables: " & Me.cmbDatabases.Text.ToUpper, 0, 0)
The children (table names) within this node are created by:
nodeTable = trvDbNameNormal.Nodes.Add(strTable, strTable, 1, 1)
What I want to do is iterate through these children to perform some SQL on the table names - but I can't figure out how to get the contents of these nodes.
|
|
|
|
|
The TreeNodesCollection class has an indexer so you can access each Node by trvDbNameNormal(0) or trvDbNameNormal(strTable) .
The TreeNode class has a Text property which will return strTable name in the case of your code.
Then simply write a recursive algorithm to walk the tree.
something like:
Private Sub walkTree(t as TreeNode)
For i as Integer = 0 To T.Nodes.Count -1
' Do something usefull here
walkTree(T.Nodes(i))
Next
End Sub
I'm largely language agnostic
After a while they all bug me
|
|
|
|
|
hi
I want to convert a HTML document into a PDF/CHM. Could someone help me? Thanks.
|
|
|
|
|
For PDFs...
Pdfizer, a dumb HTML to PDF converter[^]
CHMs are a bunch of html files compiled together. You can't directly convert an html to chm because you have to know where each page begins and ends and edit the TOC, search, and index.
|
|
|
|
|
I've been looking at my (very simple) code for the better part of 2 hours now and just can't seem to find my mistake.
I want to draw an arrow (pointing down) on a label.
so I used the fillpath methode but it doesn't work, the strange thing is that when I use the drawpath methode it does work.
here is my code:
Private Sub drawarrow(ByVal g As Graphics)<br />
If Me.Height > 30 Then<br />
Dim widtharrow As Integer = 4<br />
Dim heightarrow As Integer = 4<br />
Dim heightmargin As Integer = 3<br />
Dim x1 As Integer = (Me.Width / 2) - (widtharrow / 2)<br />
Dim y1 As Integer = Me.Height - (heightarrow + heightmargin)<br />
Dim x2 As Integer = (Me.Width / 2) + (widtharrow / 2)<br />
Dim y2 As Integer = Me.Height - (heightarrow + heightmargin)<br />
Dim gp As New GraphicsPath<br />
gp.AddLine(x1, y1, x2, y2)<br />
x1 = (Me.Width / 2) - (widtharrow / 2)<br />
y1 = Me.Height - (heightarrow + heightmargin)<br />
x2 = Me.Width / 2<br />
y2 = Me.Height - heightmargin<br />
gp.AddLine(x1, y1, x2, y2)<br />
x1 = (Me.Width / 2) + (widtharrow / 2)<br />
y1 = Me.Height - (heightarrow + heightmargin)<br />
x2 = Me.Width / 2<br />
y2 = Me.Height - heightmargin<br />
gp.AddLine(x1, y1, x2, y2)<br />
gp.CloseFigure()<br />
'gp.CloseAllFigures()<br />
'gp.FillMode = FillMode.Alternate<br />
<br />
g.FillPath(Brushes.Blue, gp)<br />
'g.DrawPath(Pens.Black, gp)<br />
gp.Dispose()<br />
End If<br />
End Sub
if anyone spots what my mistake is please let me know
thanks
|
|
|
|
|
Hi,
you want a filled triangle, right ?
I am afraid FillPath is not smart enough to correctly fill a path specified in
random order, as you did.
I would use fewer formula, set three points (x1,y1), (x2,y2) and (x3,y3)
then do AddLine(1,2), AddLine(2,3), AddLine(3,1) so the path steps through the points
1,2,3 in the right order and closes back on itself. This will give no difference to DrawPath
but it will allow FillPath to understand and fill your polygon.
BTW: in fact you dont need the third line, FillPath closes the shape all by itself
if first and last point are not the same.
Hope this helps.
|
|
|
|
|
works perfectly now
thanks
and with way less code then I did it (I think I'll take a break now )
|
|
|
|
|
you're welcome.
yes, one of my rules is: when it is wrong, trim it rather than grow it ...
Greetings from Antwerp.
|
|
|
|
|
I'm making a log file and want to have a string of apostrophes to separate parts of the log file.
Dim divider As String
Dim t As TextStream
'other declarations are there like FileSystemObject but its irrelevant. The log works besides this string I desire'
divider = "''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''"
t.WriteLine(divider)
Now I've tried using the escape character \', using hyphens (-) and asterisks(*). Any ideas?
|
|
|
|
|
Hi, string class has a constructor specially for you: new String(char, repeatCount)
|
|
|
|
|
Just curious if there is some simple code, which can be modified and implemented to click a button in an app.
|
|
|
|
|
No. Controlling an application through it's user interface is complicated and problematic at best.
|
|
|
|
|
This requires getting the handle of the other app's windows including the button that you want to click. You can then send it a message that tells the button it has been clicked. It's all Win32 API work, not terribly hard, but you can cause problems if you don't follow the rules, and you may never know all of the rules. I don't have the code any more, or I don't know where it is, but I adapted it from Bill McKinney's excellent book: Hardcore Visual Basic, Second Edition, Copyright 1997, Microsoft Press. Unfortunately it is no longer in print.
If this is important enough, and there is no other way, then I recommend you find a used copy of it. Another excellent resource is: Visual Basic Programmer's Guide to the Win32 API bu Dan Appleman. This is still in print and I consider it to be the bible of Win API programming.
Test, test, and test again.
Tom Garth
Developer
R. L. Nelson and Associates, Inc., Virginia
|
|
|
|
|