|
Nothing in your sample code throws a MyException object. Therefore you will never catch a MyException.
It would appear to me that you don't understand how exceptions work. What benefit to you anticipate your custom exception having over catching an Exception? If I knew that then maybe I could understand what you are actually trying to do, and then I could guide you better.
|
|
|
|
|
I think the contents of the try block was made up and had nothing to do with his problem. It seems that he does have a try-block that calls into something which might throw MyException, and the problem he had was that when *another* exception occured it was not caught.
The correct pattern to use has already been provided; I'll just add that the rule is to catch the most specific exception first, then less specific ones.
try
{
...
}
catch (MyException mex)
{
... // runs if try-block throws MyException
}
catch (Exception ex)
{
}
Finally, I'll just mention that a finally block might come in handy in some of these cases, such as when "cleanup" of any kind is needed - eg. close a database connection.
|
|
|
|
|
That is probably what he was actually looking for, but he did say '"MyException" must handle all the exceptions thrown by the try block'
|
|
|
|
|
Hello guys.. this is the first time im trying to make a program which uses a SQL databse file .mdf instead of a sql server.. and its also the first time i use the wizard in order to make connections and evrything else... before this all i had done it manually..
the problem im having is that after i add a row to the dataset it adds wonderfully but it does not save into the actual database file.. next time i boot up my program the row i added is not there
here is my code
Public myDataset As New ammDataSet
Try
Dim ta As New ammDataSetTableAdapters.ClientesTableAdapter
ta.Fill(myDataset.Clientes)
Dim clientRow As DataRow
clientRow = myDataset.Clientes.NewRow
clientRow.Item("cel") = "787689303"
clientRow.Item("direccion") = "something street"
clientRow.Item("email") = "huulagirl@gmail.com"
clientRow.Item("Name") = "John Doe"
clientRow.Item("tel1") = "787689303"
clientRow.Item("tel2") = "787689303"
myDataset.Clientes.Rows.Add(clientRow)
'myDataset.AcceptChanges()
MsgBox(myDataset.Clientes.Count & " " & myDataset.Clientes.Item(1).Name.ToString)
Catch ex As Exception
MsgBox(ex.Message)
End Try
what am i doing wrong? please help ive tried the acceptchanges event.. and also tried some of the alrady made by wizzard tableadapter methods and .. still no go
|
|
|
|
|
Try calling the update method of the data table and pass in the dataset.
ta.update(myDataset)
|
|
|
|
|
I created a very large dataset using the designer and now I realize that I can't access it in other forms. I have heard the way to go is to make it static although I am open to other suggestions. My goal is to keep the designer functionality because quite frankly I like the data binding features which have saved me a lot of time in other apps, but the reality is that this app requires dealing with the dataset on multiple forms.
|
|
|
|
|
You can make the dataset static (and internal / public) when it will be visible to any class in the project. In this case the dataset is created when it is referenced the first time.
If you want to control dataset creation or you want to have multiple similar datasets etc, you can create it when needed (for example in main method) and simply pass the reference of the dataset to the forms that need it.
Mika
|
|
|
|
|
Well actually that's what I didn't want to do. I want a master dataset that I can use from anywhere in my project. I have a form that all forms inherit that has an instance of this dataset set to prtected but I lose the data because it's not the same instance when it's inherited. I did find a workaround though. Instead of changing the data in the form and then trying to accessit in another form. I simply put the code that changes the database into a protected function, and then I run the function. In this instance at least, I achieve my results which is to keep the code that will be used on multiple forms on the parent form, and I can use the data on the child form. I am not sure if this qualifies as cheating or not but it does what i need it to do.
|
|
|
|
|
I see, your solutions seems working.
However, if you just simply want to share the master dataset in inheritance, you can create the dataset in the base class and let the inherited forms access it through a property getter. You can make the dataset static in base class or use singleton (which ever is more convinient).
Another point of view could be that there are certain design aspects you should consider if you combine data and user interface in same classes. For further study you could want to check for example MVC. One link for starters: Building an MVP Framework for .NET. Part 1: The Basics of MVC and MVP[^]
Mika
|
|
|
|
|
Hi All!!!
Iam working on .net from last 9 months and i had enjoyed a lot to use the extensibility of .net. But now iam facing a new problem. My client wants me to write codes for unix/linux/*nix based system to retrieve system parameters.
I am not sure whether .net will work for this or not, but for windows based system it works very fine(i had already done the same for windows)
Please help me, if there is any other language by which i can code to get parameters pls tell me. And one thing i want to add is that i haven't worked on unix earlier.
Thanks in Advance...
|
|
|
|
|
sinhasourabh wrote: Iam working on .net from last 9 months and i had enjoyed a lot to use the extensibility of .net. But now iam facing a new problem. My client wants me to write codes for unix/linux/*nix based system to retrieve system parameters.
sinhasourabh wrote: And one thing i want to add is that i haven't worked on unix earlier.
So how do you like doing Outsourcing Software Development?
led mike
|
|
|
|
|
hi folks,
I wud like to display running time in my page using javascript.For that i ve used the following client side function.
<form name="counter"><input type="text" size="8"
name="d2"></form>
<script type="text/javascript">
var milisec=0
var seconds=120
// document.counter.d2.value=0
function display()
{
if (milisec<=0){
milisec=9
seconds-=1
}
if (seconds<=-1)
{
milisec=0
seconds+=1
}
else
milisec-=1
document.counter.d2.value=seconds+"."+milisec
setTimeout("display()",1000)
}
display()
ive hardcoded it as 120 seconds.But i need to pass a value from code behind dynamically and make the timer run for that value.
for e.g i want to pass as display(180) and run the timer.Is there any way of achieving this?Advance thanx
T.Balaji
|
|
|
|
|
It'll be better if you ask the same question in ASP.NET section then it'll be easier for all and you'll get answer early
Cheers!!
Brij
|
|
|
|
|
Hi Balaji,
Use RegisterClientVariable, you may refer to the following code snippet:
At Server Side:<br />
<br />
ClientScript.RegisterHiddenField("HiddenField", "120");
At Client Side:<br />
<br />
var temp = document.getElementById("HiddenField");
I hope this would be helpful.
John Adams
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
Hi!
I've got a Windows application, and need to make a list, where each element is a block, containing a picture thumbnail, and several other controls, like on picture:
http://jamessoftware.com/misc/mylist.gif[^]
I'm C++ programmer, fairly new to C# and .NET. Could you please give me a hand with this:
- What is the best way to have this data stored internally in c# - (like a list of structures in c++)?
- Which controls should I use to make this list work? I mean what do I create in designer (VS2005), what do I need to code?
- I need to be able to drag'n'drop pictures from another list in another panel of the same form. How do I implement this drag'n'drop in both sending and receiving lists?
I'd appreciate an example or some explanation - how do you typically create this kind of thing.
Thanks a lot!
Bob
modified on Monday, August 25, 2008 4:27 AM
|
|
|
|
|
Is this a windows application or a web app? If it's a web app, you could always use a repeater control and put a panel in it with an image control in it, a couple of link buttons and some drop downs in it. I hope that helps.
|
|
|
|
|
I'm sorry, this is a regular windows application. Is there some sort of repeater for this case? I really need this. Thanks!
|
|
|
|
|
There isn't, but it wouldn't be too hard for you to code this for yourself. If I was you, I'd create a user control that contains the items themselves, and then just create as many instances as you need on the page.
|
|
|
|
|
Thanks! I've never made any user controls before - could you please point me to an appropriate sample, if you could think of any? I'm trying to find something which would look kind of similar, but can't find anything so far : (
Also, how do you scroll thru many instances of this control? Can I put it inside some list control, or I should make one on top of that control, too? Any example you could send me to, pls?
I really appreciate your help, Pete! Thanks!
|
|
|
|
|
If you can stretch to installing the WPF extensions for VS 2005, then you can do this really easily in WPF. Take a look here[^] for a sample. This type of databinding/template manipulation is an absolute breeze with WPF.
|
|
|
|
|
Oh man, this is so much new technology to get into.. Is this kind of list with custom list items be done without WPF?
Thanks!
|
|
|
|
|
You can do it with existing technologies, but it is so much more complicated. There is a lot that you have to do to bend WinForms into shape.
|
|
|
|
|
I have created a web application using visual studio 2005 (ASP.Net using C# and SQL Server 2005).Earlier, to test i created few test pages compiled them and uploaded all the related files and folders to the default virtual directory of the web server,It was working.Now, after completing the application once again I compiled the application(which is having new pages and functionality obviously) and then uploaded the complete files and folders (Before uploading I deleted all the files and folders previously uploaded to the web server from its virtual directory)When I opened my site from browser to see it working I got the old page! Even that page is not present in the directory of the web server, its still showing along with the other old pages.I want to upload my new web pages.Somebody Please help.Where am I wrong???My new pages are successfully uploaded but still old pages are coming despite of the fact that they no more exists.What is it???
|
|
|
|
|
Please First delete the old directory from the Webserver.Reset server if possible.Again upload the new one.and second remove all temp files and browser cache from the client machine.
I think it will solve your problem.
Cheers!!
Brij
|
|
|
|
|
hi all,
I am an above average programmer with experience in C++, Visual Basic. I am interested in learning .NET technology. Could any one of you please guide me where should i start. Please mention the learning phases.
Thanks.
Bye...
Khalid Mehmood Awan
|
|
|
|