|
Well, i am perplex myself also. I go to finish the application and recreate it from scratch, because i don't know what is going on. Damn, i wish i could program in VS2005
Thanks anyway for looking at my problem.
|
|
|
|
|
I want to pull data from two tables with a restriction on one field (only if a certain value). I want to then load into a dataset. Then be able to filter. Then offer user to change fields and write back to the database tables. What would be the best way to do this? I thought I could run a query to get the data in one table and then load into a dataset. But, it does not seem so easy to update the two tables. I am not familar with sql. Are there any articles you would suggest?
|
|
|
|
|
Cory Kimble wrote: But, it does not seem so easy to update the two tables. I am not familar with sql.
You're going to have to learn SQL in order to do this, or any other database related project. I highly suggest picking up a book on SQL Server 2005 and going through it. The book might come with SQL Server 2005 Express Edition (free), or you can download it from Microsoft.
If you write your query correctly, the DataAdapter object will fill a DataSet for you in as many DataTable and DataRelation objects as required.
|
|
|
|
|
I know how to use the hashtable. So far I have my program working by sending the forms to the hastable in code. Like so...
dim ptr as windows.forms.form
ptr = new frmOne
hashtable.add(ptr)
what I would like to do is replace the code above with code that will dynamically populate the hashtable, something to the effect of...
if projecttype\object\whatever is a system.windows.forms.form then
hashtable.add(projecttype\object\whatever)
I can't figure out how to do it
I tried using reflection.assembly.getexecutingassembly however a forms BaseType is not always stated as system.windows.forms.form it can also be the project namespace.formname, which completely negates the whole purpose of using it.
Ferron
|
|
|
|
|
I've got a bigger question. Why are you trying to do this at all?? What's the point of jumping through all these hoops?
|
|
|
|
|
I need to create a hashtable collection of all the forms in my project.
It needs to be done in code and it needs to be done without any user input.
It also needs to be able to be portable from one project to another without rewritting any code, so the list needs to be created dynamically.
Do u know how to achieve this, or can anyone point me in the correct direction?
Thanks
Ferron
|
|
|
|
|
ferronrsmith wrote: I need to create a hashtable collection of all the forms in my project.
It needs to be done in code and it needs to be done without any user input.
I'll ask again. Why??
|
|
|
|
|
Hello,
I have a VB.net Windows forms application that utilizes a rather large label control to display weights from a scale. My only problem is that I can't get the label.text alignment right. The text appears to go completely off the area that the label occupies. I've tried every setting for the "TextAlign" property. They all seem to go whack-o. Any ideas on what could be causing this bizarre behavior?
Thanks,
T-Tops
|
|
|
|
|
Is the label's AutoSize property set to False?
Other than that, there isn't sufficient information to tell you anything except how to label control works. How did you setup this label?? How long is the Text string?? Does it actually overflow the left, right side, or both sides, of the label? Are you looking for a single line of text to fit in the label as a single line?? Are you trying to break up the text so it occupies multiple lines in the label?
|
|
|
|
|
T-Tops wrote: They all seem to go whack-o
That makes the diagnosis very easy. You could Google that.
I'll try to give some ideas anyway:
Normal alignment is "TopLeft"; to right align choose "TopRight".
If you want to get a range of numbers at regular intervals (that is not an alignment issue!),
and you want to do that with just a single control, you should choose a "non-proportional"
font such as "Courier New".
If you want to be in charge of the label size, set AutoSize false.
If the text width exceeds the label width, text will wrap to the next line (and lacking
the necessary height it may be invisible).
If none of the above help you, try this:
- show the code
- give a decent description of what you get and what you want it to be
- for visual stuff, if possible, show an image
|
|
|
|
|
Hey guys, I have a question that I hope isn't too hard to get an anwser too, although even after all the Googling, and searching Code Project I've done I haven't had much luck yet.
What I'm trying to do is make a Datetime field in a SQL database null (it's already set to allow nulls), but no matter how many different ways I try I either get an error or the default lowest time is just filled in (1900/01/01 12:00:00 AM).
A time being there relys on the users input, so in some cases it might need to be filled in, in other cases it doesn't.
Anyway, here is my code, if anymore is needed just ask!
Dim DateClosed As Date
State = (ddlState.SelectedItem.Value)
If State = 0 Then
DateClosed = CDate(lstYear2.SelectedValue & "/" & lstMonth2.SelectedValue & "/" & lstDay2.SelectedValue)
Time = " " & ddlHour2.SelectedItem.Value + ":" + ddlMin2.SelectedItem.Value + ddlAMPM2.SelectedItem.Value
DateClosed += Time
Else
DateClosed = Nothing
End If
Just incase anyone needs to know, State is a drop down box with two selections. Open or closed. Open = 1 and Closed = 0.
Thanks,
aqzman
|
|
|
|
|
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
|
|
|
|