|
i dint use dataset ...i read data using datareader...Below is a portion of my code
If strfee = "consultation fee" Then
cmd1 = New OleDbCommand("select fees from fee_details where type='" + doctorcombobx.SelectedItem + "'", con1)
dr1 = cmd1.ExecuteReader()
If dr1.Read() Then
consult_fee = dr1.Item(0)
End If
consult_count = DataGridView1.Rows.Count()
DataGridView1.Rows.Add()
DataGridView1.Rows(consult_count - 1).Cells(0).Value = billcombobox.SelectedItem
DataGridView1.Rows(consult_count - 1).Cells(1).Value = consult_fee
Else
cmd2 = New OleDbCommand("select fees from fee_details where type='" + billcombobox.SelectedItem + "'", con1)
dr2 = cmd2.ExecuteReader()
If dr2.Read() Then
bill_fee = dr2.Item(0)
End If
bill_count = DataGridView1.Rows.Count()
DataGridView1.Rows.Add()
DataGridView1.Rows(bill_count - 1).Cells(0).Value = billcombobox.SelectedItem
DataGridView1.Rows(bill_count - 1).Cells(1).Value = bill_fee
End If
|
|
|
|
|
Not a big problem. Right now you are storing the data in the DataGrid. All you need to do is store it in a DataTable first (the code will look pretty much the same), and bind the datagrid to this DataTable.
Something like:
Dim BillInfo As DataTable = Nothing
Dim clmn As DataColumn = Nothing
Dim rw As DataRow = Nothing
Try
BillInfo = New DataTable("DataTable1")
clmn = New DataColumn("PatientName")
BillInfo.Columns.Add(clmn)
clmn = New DataColumn("Address")
BillInfo.Columns.Add(clmn)
clmn = New DataColumn("Total")
BillInfo.Columns.Add(clmn)
'etc
rw = BillInfo.NewRow
rw.Item("PatientName") = YourDataReader.Item("NameOfColumn")
'Using the name of the column instead of the index number will
'save you a lot of trouble later on, if you ever want to
'add fields to your query.
BillInfo.Rows.Add(rw)
'etc
'And then when the DataTable is ready:
DataGridView1.DataSource = BillInfo
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Also, in the code you posted, you are not using a loop with the datareader.
Try something like:
dr1 = cmd1.ExecuteReader()
If dr1.HasRows Then
Do while dr1.read()
rw.Item("PatientName") = dr1.Item("NameOfColumn")
Next
End If
My advice is free, and you may get what you paid for.
|
|
|
|
|
thanks johan...its getting dark here..i should go home now ..once i reach home i will try this out
|
|
|
|
|
You can use dataset to store data from Windows Form and then Fatch the data in crystal Report.
If you can think then I Can.
|
|
|
|
|
Hi All,
I am creating control at runtime. so these are overlapping and hiding.
So i want to use Send to Back or Bring to Front for it.
So Please give me idea for implimenting it.
Thanks
If you can think then I Can.
|
|
|
|
|
You'll probably want the BringToFront and SendToBack methods
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Is there something like zindex?
google for that.
Coding C#
www.excitetemplate.com
|
|
|
|
|
Thanks Sir
If you can think then I Can.
|
|
|
|
|
A question I should have probably wondered about a little earlier, but anyway:
Let's say I dim an object, for example a dataset, fill that object with data, and use the object, but do not explicitly clear/empty it after use. Then reuse it like:
MyObject = New Object
Will that automatically clear/empty the data from it, that I filled it with earlier? Or does this depend on the object?
Perhaps the important question here is: what is best practice? Can I get problems by not explicitly clearing/emptying an object before reusing it?
My advice is free, and you may get what you paid for.
|
|
|
|
|
Hi,
assuming VB.NET, if you do
[1] Dim MyObject As Object
[2] MyObject = New Object ' object 1
[3] MyObject = New Object ' object 2
then object 1 will become collectible when line [3] executes, meaning the garbage collector will collect object 1 the next time it runs (normally it runs when a future memory allocation cannot be satisfied without cleaning up memory first).
And this is fine, unless it is a type that implements Dispose or Close, as in:
[1] Dim MyObject As Font
[2] MyObject = New Font(...) ' object 1
[4] MyObject = New Font(...) ' object 2
now you should insert [3] MyObject.Dispose() to make sure the unmanaged resources that might be held by the object get released right away (or the file or stream or whatever gets closed).
If you don't Close/Dispose objects that support it, your app will use more memory and other system resources, and its behavior may deteriorate. Yes, the garbage collector will still find those objects, and its finalizer thread will eventually Dispose of them, but that typically will be much later.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi Luc,
Thanks, that is really good to know. So far I just assumed that once I reused the object, it would automatically also dispose of the first object and all related data.
So from your explanation, can I surmise that it would be good practise to change my current code (simplified) from:
Dim ds As DataSet = Nothing
ds = New DataSet("DataSet1")
'Run a query and fill the dataset here
'Run some loops, and do some stuff to the data
ds = New DataSet("DataSet1")
'Run another query and fill the dataset here
'Run some loops, and do some stuff to the data
to
Dim ds As DataSet = Nothing
ds = New DataSet("DataSet1")
'Run a query and fill the dataset here
'Run some loops, and do some stuff to the data
ds.Clear() 'Would this even be necessary ?
ds.Dispose()
ds = New DataSet("DataSet1")
'Run another query and fill the dataset here
'Run some loops, and do some stuff to the data
In other words, my app would at least use less resources while it is running?
Cheers,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
Calling Dispose()/Close() when done with an object that has such method is good.
Calling Clear() or Flush() or ... typically doesn't change a thing when immediately followed by Dispose/Close.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Alright, great !
Thanks a bundle for the enlightenment
My advice is free, and you may get what you paid for.
|
|
|
|
|
you're welcome.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi,
I have tabcontrol with 5 pages. On some action I want to bring page 3 to the front..
thanks
|
|
|
|
|
Forgive any syntax errors in this, I'm doing it from memory, but something like:
myTabControl.SelectedTab = myTabControl.TabPages(2);
[Edit]
changed indexing from [] to (). Forgot I was in the VB forum.
Anyway Lucs' solution, below, is better more concise.
[/Edit]
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
modified on Thursday, August 13, 2009 5:54 PM
|
|
|
|
|
or...
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Yup.
I don't use the TabControl often, and had forgotten that, If I ever knew it!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
myTabControl.SelectedIndex=2;
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I have a DVD with 15,000 word documents (transcribed op reports from doctors).
I need to organize them by date modified into folders, year first, then a month subdirectory.
The filenames have a date string in them after a patient name.
i.e.: smith john -20060415.doc
I'm wondering if it would be easier to use the fileinfo feature to pull the modified date, and then utilize that to make a folder for the month, then drop that in a folder.
I dont have any code yet, I'm in more of a brainstorming mode, but we will have to do this for a few hundred other accounts we have and need to have a working solution for this issue.
Excuse the pseudo-code, but here's my general idea.
I'd just like some guidance as to what commands I should use in this situation
-scan dir for files *.doc
-for loop
-get modified date of file
-does month folder exist
y=copy file
n=create folder
-copy file
next
Am I on the right track?
Thanks for any response, even if its "you're in the wrong forum" =)
-STL
|
|
|
|
|
The logic is pretty basic, but works. But, I'd do some sanity checking first. If you have the date information in the filename, Id start by parsing that out and comparing it to the Modified date on the file. If the two aren't within some arbitrary limit, I'd set the file aside for further review of where it should go, otherwise, I'd follow the logic you already have.
|
|
|
|
|
Thanks! Now to get it out before friday...
|
|
|
|
|
You're on the right track; you just need to expand on your pseudocode. Perhaps something like this:
-scan for *.doc files
-for each doc file
--get modified data
--create full path from concatenated data
--does directory exist?
---no: create it
--move file to directory
-end for each
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
are you sure you want to categorize by date? That would make retrieval difficult if all you know is patient name or patient number.
How about dividing the lot you have now in folders according to say the first two or three characters of the current filename (so "smith john -20060415.doc" would end up in "sm" or "smi"). That would potentially lead to a few hundred or thousand folders. These folders would vary in the number of files they contain much more than your scheme, however this scheme would keep patient information for a single patient in a single folder, which any date based scheme does not.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Yes, it needs to be by date. The center that is requesting the archive DVD uses our software to pull the files from our SQL DB. The program they use has a listing of job numbers, and of the files, and other information, but we do not allow them remote access to them as they are from 2003-2006, and our cutoff is 01-01-2007.
They will be able to search the disk for the files using windows search, and we have yet to come up with a standard naming convention, so our office manager (not too tech savy) wants them in folders by year, 2003; 2004; 2005...etc and then by month.
So I'm just going with what he wants, but moving and creating folders for 15000 files is too time consuming, so I just need an app to do it for me.
between u, me, and the fencepost, I dont care how they use the disk, I just need to job done. lol.
I appreciate everyone's input. I'll be working on this tonight to get it out in tomorrow's End of Day, so stay tuned as I might need help with the code. ty all!
|
|
|
|