|
You're welcome.
PS: please don't delete messages, it easily makes the threads look strange. When you change your mind, just add a sentence ("ignore", or "changed my mind to....").
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’m practicing a database and I have a 3-column table. I’m using binary formatting to save/open the file. I can’t see what is wrong with my code –
I can display records in the datagrid view ok when I press the save button
I can also save the records into the dataset ok when the save/close button is pressed.
When I reopen the programme and press the reload button to reload the dataset, additional records will not be displayed nor saved though original records will be showing in the datagrid.
When I reopen the programme and DO NOT press the reload button, I can enter new records and they will be saved because this is basically overwrites the original dataset.
Ideally, I want to be able to open the dataset and then be able to add new records to the dataset/datatable.
Any help and advice on how to correct this?
Thanks,
Steve
Here is my code:
Imports System.IO
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Formatters.Binary
Public Class Frm_DataEntry
Dim ThePoint As New Point(540, 150)
Public TheRecord As DataRow
Dim ii As Integer
Private Sub Frm_DataEntry_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.Location = ThePoint
End Sub
Private Sub Tbx01_FirstName_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Tbx01_FirstName.Enter
Tbx01_FirstName.Clear()
Tbx02_LastName.Clear()
Tbx03_Phone.Clear()
End Sub
Private Sub Btn01_Save_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Btn01_Save.Click
TheRecord = Frm_Mainform.dt_Table.NewRow
TheRecord(Frm_Mainform.dt_Col02_FirstName) = Tbx01_FirstName.Text
TheRecord(Frm_Mainform.dt_Col03_LastName) = Tbx02_LastName.Text
Frm_Mainform.dt_Table.Rows.Add(TheRecord)
Frm01_WithDGV.DGV01.DataSource = Frm_Mainform.ds_Dataset
Frm01_WithDGV.DGV01.DataMember = Frm_Mainform.dt_Table.ToString
Frm01_WithDGV.DGV01_BS_Col01_PKey.DataPropertyName = Frm_Mainform.dt_Col01_PKey.ToString
Frm01_WithDGV.DGV01_BS_Col02_FirstName.DataPropertyName = Frm_Mainform.dt_Col02_FirstName.ToString
Frm01_WithDGV.DGV01_BS_Col03_LastName.DataPropertyName = Frm_Mainform.dt_Col03_LastName.ToString
Dim ii As Integer
ii = Frm_Mainform.dt_Table.Rows.Count
MessageBox.Show(ii)
End Sub
Private Sub Btn02_SaveAndClose_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Btn02_SaveAndClose.Click
Dim Filename As String = "PermitToWork.pmt"
Dim fStream As FileStream
Frm01_WithDGV.DGV01.DataSource = Frm_Mainform.ds_Dataset
Frm01_WithDGV.DGV01.DataMember = Frm_Mainform.dt_Table.ToString
Frm01_WithDGV.DGV01_BS_Col01_PKey.Width = 90
Frm01_WithDGV.DGV01_BS_Col02_FirstName.Width = 125
Frm01_WithDGV.DGV01_BS_Col03_LastName.Width = 125
Frm01_WithDGV.DGV01_BS_Col04_Date.Width = 125
Frm01_WithDGV.DGV01_BS_Col01_PKey.DataPropertyName = Frm_Mainform.dt_Col01_PKey.ToString
Frm01_WithDGV.DGV01_BS_Col02_FirstName.DataPropertyName = Frm_Mainform.dt_Col02_FirstName.ToString
Frm01_WithDGV.DGV01_BS_Col03_LastName.DataPropertyName = Frm_Mainform.dt_Col03_LastName.ToString
If File.Exists(Filename) Then
Try
fStream = New FileStream(Filename, FileMode.Create)
Dim binFormat As New BinaryFormatter
binFormat.Serialize(fStream, Frm_Mainform.ds_Dataset)
Catch anex As ArgumentNullException
MsgBox("The inventory could not be accessed")
Catch ex As SerializationException
MsgBox("The application failed to retrieve the inventory")
Finally
fStream.Close()
End Try
Else
Return
End If
Frm_Mainform.Close()
End Sub
Private Sub Btn03_Reload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Btn03_Reload.Click
Dim Filename As String = "PermitToWork.pmt"
Dim fStream As FileStream
If File.Exists(Filename) Then
Try
fStream = New FileStream(Filename, FileMode.OpenOrCreate, FileAccess.ReadWrite)
Dim binFormat As New BinaryFormatter
Frm_Mainform.ds_Dataset = binFormat.Deserialize(fStream)
Frm01_WithDGV.DGV01.DataSource = Frm_Mainform.ds_Dataset
Frm01_WithDGV.DGV01.DataMember = Frm_Mainform.dt_Table.ToString
Frm01_WithDGV.DGV01_BS_Col01_PKey.Width = 90
Frm01_WithDGV.DGV01_BS_Col02_FirstName.Width = 125
Frm01_WithDGV.DGV01_BS_Col03_LastName.Width = 125
Frm01_WithDGV.DGV01_BS_Col04_Date.Width = 125
Frm01_WithDGV.DGV01_BS_Col01_PKey.DataPropertyName = Frm_Mainform.dt_Col01_PKey.ToString
Frm01_WithDGV.DGV01_BS_Col02_FirstName.DataPropertyName = Frm_Mainform.dt_Col02_FirstName.ToString
Frm01_WithDGV.DGV01_BS_Col03_LastName.DataPropertyName = Frm_Mainform.dt_Col03_LastName.ToString
Catch anex As ArgumentNullException
MsgBox("The inventory could not be accessed")
Catch ex As SerializationException
MsgBox("The application failed to retrieve the inventory")
Finally
fStream.Close()
End Try
Else
Return
End If
Frm01_WithDGV.DGV01_BS_Col01_PKey.Width = 90
Frm01_WithDGV.DGV01_BS_Col02_FirstName.Width = 125
Frm01_WithDGV.DGV01_BS_Col03_LastName.Width = 125
Frm01_WithDGV.DGV01_BS_Col04_Date.Width = 125
Dim ii As Integer
ii = Frm01_WithDGV.DGV01.Rows.Count
MessageBox.Show(ii)
End Sub
End Class
Thanks for your help and advice!
Steve
Thanks for your help and advice!
Steve
|
|
|
|
|
One possible reason that your question has not been answered is that it is too difficult to read your code sample.
If you place it between pre tags and format it properly you will have more chance of getting an answer.
<pre>
put your code here
and indent it properly
</pre>
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.”
|
|
|
|
|
Is thier any MCE examples out thier or a greate article creator to pls create one.
Im in real need on how this MCE fits together & a simple example to show it all.
|
|
|
|
|
What's this "MultiChannel Engine" thing?
Do you have any link?
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
|
Hi all,
I am not clear if this the right forum for this question !? (or administration ?)
As the starting condition of my setup file (msi) I have to determine if .NET Framework X.Y is already installed.
So I need the componentID of the relating framework. I seeked the registry but I found hundreds of guid's.
Where do I get the correct one ?
Thanks in advance
Frank
PS.: I am missing a forum for installer-questions (is there a one ?)
|
|
|
|
|
If your installer includes files that require .Net then VS should automatically add a .Net Prerequisite to the "Launch Conditions" page in the VS Editor. If you click on that prerequisite you can view its properties and change the .Net version number to whatever you want.
If that isn't working for whatever reason this[^] article may help.
|
|
|
|
|
Hi Jimmanuel,
thanks for your answer.
The VS2008 installer addeted automaticly the Prerequisite (but the wrong one) .NET v3.5 instead of .NET v2.0 (my app was compiled for .NET2.0) and left the componentID free. So I came back to my question - where to get this componentID (GUID) or what checks the installer to determine if the correct version is installer or not. - The article doesn't tells somthing about it.
Thanks
Frank
|
|
|
|
|
Hello friends,
I've a interview for .Net Developer with 1 year experience.I waan possible interview question with answer.Thanks in advance.
Cheers,
MAHESH.K
|
|
|
|
|
What is the company you are interviewing with? I'll just give them a warning to pass on your interview.
only two letters away from being an asset
|
|
|
|
|
They will probably ask how well you know .Net, the probably answer in your case seems to be not very well.
Good luck!!!
|
|
|
|
|
If I'm the interviewer I'll sit you in front of Visual Studio and set you a task. I will explain the task in detail. I'll show you the resources you need to complete the task. I'll let you know that the machine has an open internet connection so it is a real life test, you can use any resources any of our existing developers will have access to. Before I leave you to the task I'll makes sure you understand and give you an opportunity to ask any questions you may have. At any time you can ask me or my colleagues questions.
After 2 to 4 hours (depending on the experience you've told me you've already got) I'll see how you are getting on. You will walk me through the code you have written and explain how it works and how it fits together. So far, only one person ever completed the entire task, so I'll ask what you would continue to do if you had the time to complete the task.
So, no questions. If you can talk-the-talk that's doesn' necessarily mean you are any good. If you can walk-the-walk then I'll take you seriously.
|
|
|
|
|
Would you mind giving an example of one such task? (I'd like to see how close I could come)
|
|
|
|
|
harold aptroot wrote: Would you mind giving an example of one such task?
Well, without being too specific (I don't want to have to come up with a new one, and I don't want to give away too many details - some job seekers are wiley and can use the inter-tubes) it would involve the following:
Some sort of user interface, candidate gets the choice or WinForms or Web Application (I suppose WPF could be included). There is a data source involved, we provide a flat file, XML file or database and candidates can choose which they'd prefer (they also get the option of re-designing the data format as there are slight flaws).
The application consists of some sort of input which dictates which data to display. There is also some data that is disconnected from the data source (say some graphics files). And there are some inconsistencies in the way things are names.
What we are looking for is: Is everything set out logically? Are any of the flaws in the spec or source files (data, graphics, etc.) provided resolved? Does the program work (at least to some extent). Did they make any unit tests?
I suppose something along the lines of a stock system where you can put in a product category and get back a picture along with current inventory levels and price would fit the bill.
For bonus points (if they finish the main part of the exercise) make it editable.
You now have 4 hours. GO!
|
|
|
|
|
Seriously, if you want to give it a go I can see if I can come up with a spec and some files. Or you can first off design some database and flesh out a specification based on my previous description and follow that through.
|
|
|
|
|
Harold,
I've found an older version (WinForms only version). I can send it to you if you wish. Just use the email link on this message to get in touch and I'll send it over.
Regards,
Colin.
|
|
|
|
|
Thanks for the offer but I think you've told me enough, I was mostly just curious about what kind of thing I could expect
I have a feeling that I could pull it off, but it's the holidays for me and I'm afraid laziness wins today (I'm a student, need I say more? )
|
|
|
|
|
Sounds a really good candidate for an article mate.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
i am the beginer for .net, i need to bind records into gridview using data reader,
please help me, how to do this..
|
|
|
|
|
this is very easy, first declare data reader and provide obj for data reader and read each and every row using for loop and bind the gridview columns.
|
|
|
|
|
Quite easy, first declare some list with type of your data wrapper, then read db via reader and populate one warper object with data from reader for each row and add it to declared list. Lastly you need to set gridview data source property to your declared list and call bind on gridview that's it.
|
|
|
|
|
Check out
http://www.dotnetspider.com/resources/21557-Code-bind-gridview-with-data-reader.aspx
|
|
|
|
|
I have a report that needs printing, it's over 6000 pages (A4) from a dataset built in memory. I'm using the "normal" reportviewer control, and the generation of the report to the viewer seems fine, however when the report is sent to the printer it crashes after about 2000 pages, sometimes throwing an exception in GDI, sometimes (I'm not sure why) silently (ie stops sending pages to the printer). Having watched the memory usage on the machine that this is running on I discovered that it's not running out of memory (as I first assumed).
Does anyone have A. Any idea what is going on and how to get around it, or B. A reporting tool that's better suited to printing (not saving to file) very large reports.
Thanks
Simon
|
|
|
|
|
Simon Minich wrote: sometimes throwing an exception in GDI,
It seems the printer driver is having problems handling the volume of data. Sorry if I'm stating the obvious, but it seems there's little you can do to work around this other than printing the report in chunks.
/ravi
|
|
|
|