|
The code looks OK. I don't see why you'd get IndexOutOfRangeException for some rows but not others.
|
|
|
|
|
Terick wrote: (reader)["size"]
I am not getting this?
By the way try this:
private static Name GetNameFromReader(IDataReader reader)
{
Name name_obj = new Name(
(int)reader["ID"],
(reader["size"] != DBNull.Value)? (int)reader["size"] : (int)0);
return name_obj;
}
Be careful, there is no Undo Button(Ctrl+Z) in life.
|
|
|
|
|
|
Terick wrote: otherwise the cell will be empty
Hmm.... Now i get it.
string.IsNullOrEmpty(reader["size"]) ? 0 : (int)reader["size"]
|
|
|
|
|
Hi,
Ever used the old DataGrid control "not the DataGridView" and wanted to add a comboBox column?? Well, I'm trying to do so and according to many websites they have it under System.Windows.Forms namespace but I just cant find it in the intelisense....
Pleeeeeeeeeez help guys!
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hi,
I had a quick rummage in the MSDN library. It reports that that control isn't in the System.Windows.Forms namespace, but instead is in Microsoft.CLRAdmin. It's also marked as 'This class supports the .NET Framework infrastructure and is not intended to be used directly from your code.' This suggests to me that if what you want to do is possible, it has to be done another way. Perhaps there is a method on one of the other DataGridView classes to add it for you.
I'm sorry this doesn't really solve your problem, but it does answer your question
Also, a free tip: Adding things like
Muammar© wrote: Pleeeeeeeeeez help guys!
won't help you get an answer. The people on this site seem to generally quite helpful, so you don't need to beg, and comments like that can be seen as annoying (particularly the spelling of 'please').
|
|
|
|
|
I'm currently in the process of refactoring a web app to make it more testable and have posted here about it.
I've managed to move forward a lot but now I'm in the situation where I perform the dependency injection on the constructor or via setting properties and the number of items needed is increasing e.g. Membership, state management, meta data provider etc.
Although I could look at using static classes within the assembly I need to provide the implementation to be used from outside the assembly e.g. web app creates instance of class providing the relative dependancies and I am also concerned about the testability of static classes.
Any suggestions about approaches I could take or patterns I could follow would be greatly appreciated.
|
|
|
|
|
Some cross-cutting concerns can be aggregated into "context", which is usually globally accessible. Think of HttpContext...you can access it anywhere via HttpContext.Current. Think of context from a grammatical perspective...certain words or phrases only have meaning when they are taking "in context". Same general idea with programming. A piece of code really only works when you factor in the appropriate context(s). Not everything needs to be injected, some things should be globally accessible via one or more contexts. This might help lighten your DI load so that you are only injecting direct dependencies of each class, while keeping global dependencies properly centralized.
|
|
|
|
|
DateTime dateRented = rental_InvoiceTableAdapter1.getTimeRentedbyInvoiceNo(int.Parse(txtInvoiceNo.Text));
I can't figure out why I'm getting this exception thrown by this code. I'm trying to collect a single cell from the DateTime column "Time_Rented" using a SQL statement. The SQL statement works fine in the query builder, so it has to be something in the C# code.
The entire error message is:
"Cannot implicitly convert type 'System.DateTime?' to 'System.DateTime'. An explicit conversion exists ( are you missing a case?)"
Both sides of the statement are DateTime, aren't they? I don't understand why it can't convert it.
Please help!
|
|
|
|
|
Lodeclaw wrote: System.DateTime?
What is System.DateTime? ?
I have only heard of System.DateTime .
Try removing the "?".
Kristian Sixhoej
"You can't undo the past... but you can certainly not repeat it." - Bruce Willis
HAI
CAN HAS STDIO?
PLZ OPEN FILE "SIGNATURE.TXT"?
AWSUM THX
VISIBLE FILE
O NOES
INVISIBLE "ERROR!"
KTHXBYE
|
|
|
|
|
That's confusing me, as well. I didn't type System.DateTime? anywhere. If I had typed it incorrectly the debugger would have notified me when I typed it. I'll do a search for it, anyway.
|
|
|
|
|
It's a nullable datetime. int? is a nullable int, for example.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Look closely at the message. DateTime? is a nullable DateTime. You'll have to do the explicit conversion
[EDIT] or alternatively declare you date rented as the nullable DateTime? type.
Alan.
|
|
|
|
|
I've been trying to do the explicit conversion. How do I know what the explicit conversion is? I've tried DateTime.Parse the query results as a string and I've tried Convert.DateTime . Can you offer any other possibilities?
|
|
|
|
|
DateTime? is short-hand for Nullable<DateTime> , using the Nullable<T> class introduced in .NET Framework 2.0. The Nullable types are actually a class that is a wrapper around a value type. To get the underlying value from a Nullable<T> , use the Value property like so:
DateTime dateRented = rental_InvoiceTableAdapter1.getTimeRentedbyInvoiceNo(int.Parse(txtInvoiceNo.Text)).Value;
Or you can declare dateRented as Nullable<DateTime> (same as DateTime? ) rather than a normal DateTime , like so:
DateTime? dateRented = rental_InvoiceTableAdapter1.getTimeRentedbyInvoiceNo(int.Parse(txtInvoiceNo.Text));
OR
Nullable<DateTime> dateRented = rental_InvoiceTableAdapter1.getTimeRentedbyInvoiceNo(int.Parse(txtInvoiceNo.Text));
The message really means that the getTimeRentedbyInvoiceNo() function is returning a DateTime? and you are trying to stuff that return value into a DateTime ; and they are two different types.
Hope in one hand and poop in the other; see which fills up first. Hope and change were good slogans, now show us more than words.
|
|
|
|
|
I tried those and even though the debugger is ok with them, and the other conversions I've tried, I get an exception telling me the input value is not in the correct format.
|
|
|
|
|
Lodeclaw wrote: I get an exception telling me the input value is not in the correct format.
This may be a different problem now. Where did the exception arise and do you know that the result of int.Parse is valid input for your function?
Alan.
|
|
|
|
|
For some reason the query that fills the txtInvoiceNo textbox is not yielding a result, so my input is an empty string. I'll have to figure out why that is.
In any case, this problem is solved, then. Thanks everyone for helping this poor noob. I learned some new things.
|
|
|
|
|
I'm sorry about my English.But I wish you guys can understand what I said.
I wanna made a modal popup window when the application is executing.
Show some information to user,maybe execute message like "please wait..." or a progress bar something.
How to create a modal dialog during execution in winform?Give me sample source code would be better.
The Main Form will stoped execute when Form.ShowDialog(). I need show the popup form,and the main form still execute.
like this:
void subA()
{
ShowExecuteDialog(); //when show this popup dialog,still execute functionA,b,c,d..
FunctionA();
FunctionB();
FunctionC();
FunctionD();
CloseExecuteDialog();
}
modified on Thursday, February 5, 2009 5:14 AM
|
|
|
|
|
well i assume you can create a form and show that from another form?
well when you show the 'pop-up' form just use form.ShowDialog(); that will make it the only focusable form and well wait for user to click a button to close. On which you need to handle the button click and either .Hide() or .Close() the form. If you want to access propoerties from the form then you will need to use .Hide() so it doesnt dispose of all data
My opinion is... If someone has already posted an answer, dont post the SAME answer
|
|
|
|
|
you can show the any other form as modal dialog by calling showdialog method and passing the current form as parent.
Form messageForm = new Form();
messageForm.ShowDialog(this);
Be careful, there is no Undo Button(Ctrl+Z) in life.
|
|
|
|
|
No.If just showDialog.The Main Form stoped execute.I need show the popup form,and the main form still execute.
|
|
|
|
|
Ummm, you wanted to show a Modal Dialog. The UI thread on the form that launched the modal stops executing until the modal dialog is dismissed. That's the expected behavior.
If you have to have elements on the main form still responsive to the user, you have show the dialog as a normal form, not modal. If you just have code in the main form that needs to execute without user or UI interaction, then you have to move that code to a seperate thread, then you can show your other dialog modal.
|
|
|
|
|
Hi
Let's think that there is an application which asks you your name at the first start. You enter it and it saves it. Next time you start the application, it doesn't ask your name. It says "Hello ....." .
But it doesn't save your name to registry nor a file. Is this possible? And how can I do this?
Actually this is just a simple example to tell you what I want to do. In short I want to save a string into the EXE, but it should be changeble by the same application.
Thanks.
|
|
|
|
|
Ive never done it, and dont know if possible but i can offer a theory that may lead you somewhere:
Lets say for example you hardcode a string that is 100 chars long. When you compile you application that string is stored in the .exe somewhere. Now if you could find out how .exe are compiled you may be able to find the byte range for that hardcoded value somehow. Then maybe you could write what ever string to that byte range and it would save... Theoretically.
Of course you will have to get around a write issue, when trying to write to the app you are running lol
Maybe, you have a second app that is called, closes the first app, writes the value, then executes the first app again. This is getting rather tediuos thou so im sure you want want to take this route.
But if you do go for it, then dont forget to post any results you find, im sure people would be interested
My opinion is... If someone has already posted an answer, dont post the SAME answer
|
|
|
|