|
Hello,
First of all, null is not a datatype, it is a keyword which represent null reference. A null reference is reference which does not refer to any object. Also null is the default value for all reference-type objects.
ma se wrote: If I want to create a similar function like this to return DBNull.Value, can I do the above mentioned if, if enmpty, the I return DBNull.Value? Is this the right way to coding it?
Yes you can do the same for DBNull. You will have change the signature of the method to
public static DBNull GetString(string textBoxString)
ma se wrote: What if it is an int value?
I could not understand this question.
ma se wrote: When I have a variable that is null and add it to my table, then it seems to add a null value to the field, nulls values look like in SQL Server 2000?
It is DataColumn 's implementation which treats null as DBNull.Value . Therefore it'll save the null values in the DataTable to SQL Server 2000 as DBNull.Value .
Maqsood Ahmed - MCAD.net
Kolachi Advanced Technologies
http://www.kolachi.net
|
|
|
|
|
Ok thanks.
Maqsood Ahmed wrote: public static DBNull GetString(string textBoxString)
Because the above mentioned function returns DBNull.Value if the string contains a null value, so it can return a string value if the variable contains something?
Thanks for all the answers you have given me, it has helped a lot.
Regards.
|
|
|
|
|
Hi,
I tried the following function, but it doesn't want to work:
//*********************************************************************
//
// CheckStringForDBNulls Static Method
//
// The CheckStringForDBNulls method checks if a string contains a value, if not it
// returns DBNull.Value, or the value of the string.
//
//*********************************************************************
public static DBNull CheckStringForDBNulls(string strCheckString)
{
if(strCheckString.Trim() != string.Empty)
return strCheckString.Trim();
else
return DBNull.Value;
}
Could you please let me know what I am doing wrong? This is used to check the parameter being added, if it contains nothing, the make the value DBNull.Value, or use the value of thr string.
Thanks
BRENDAN
|
|
|
|
|
I need to create a timeline control in C# and I'm not sure how to begin. I am new to C# (and custom control development for that matter) and I need to create this timeline ASAP.
What would be perfect is if I could quickly create a control that does the same thing as the timeline control in Windows Movie Maker. I need to be able to drag & drop movies from a collection (just like the collections in "Windows Movie Maker") into the timeline and each successive movie should be automatically placed directly after the previous one. I really like the timeline in Windows Movie Maker (also similar to the timeline in Adobe Priemier) because its easy to drop any video file into the timeline.
If anybody has any great insights on how to start (which controls to inherit from in order to get the starting functionality I need, or knows of any examples on the internet on how to create this type of control) any support would be greatly appreciated!
Thanks in Advance,
|
|
|
|
|
Hi,
I have the following piece of code.
private string strName;
if(txtName.Text.Trim() != "")
strName = txtName.Text.Trim();
Then I want to pass this variable to a constructor like:
Customer objCustomer = new Customer(strName);
Now strName may be null, or not. So if the if statement fails, then the value of strName is null? But it complains when I compile, and says that no value was set for strName when I pass it to the Customer constructor. So what I did was to define it like:
private string strName = null;
Which works fine, but I thought the default value for string is null?
Regards
|
|
|
|
|
Compiler warn you, it there is usage of uninitializated variables (i hope you write code without warnings). So if default value is null you can easily check for it - (vaiable != null).
Your code works fine because of null is valid value for object.
BTW. It is better way to write page-behind classes instead of usage of form class, it is more clean to understand and can be useful for reflection operations
|
|
|
|
|
ma se wrote:
Which works fine, but I thought the default value for string is null?
That's true only if strName is a member variable. Local variables need to be initialized explicitly.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
The compiler will error out if you don't initialize the variable before setting it. In this case it doesn't matter whether or not strName is null, you just have to set it first. Try this code bit:
<code>
private string strName = null;
if(txtName.Text.Trim() != "")
strName = txtName.Text.Trim();
</code>
A more safe and better way to do this would be:
<code>
private string strName = null;
if(txtName != null && txtName.Text.Trim().Length > 0)
strName = txtName.Text.Trim();
</code>
|
|
|
|
|
I have 2 separated solutions one for my asp.net application and the other is components solutions , in application i added a reference from one of DLLs that are generated in specific folder (such C:\Components), my problems in certain situation i have to debug the DLL with the current parameters , but i can though its a debug version, what is the avaiable techniques to do this ?
|
|
|
|
|
Did you try attaching to the ASP .NET worker process (aspnet_wp or something similar)?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
thanks for reply , i attached the process and also copy the pdb file in component location, so now am able to debug the dll.
Thanks
|
|
|
|
|
Hi there,
Just a couple of questions:
I have 2 select boxes. When you select a region in the first select box, it loads all the areas associated to the selected region in the second textbox. Now I also have validation controls on the webform. Whenever the areas are loaded, then it seems to take away my error messages of the validation controls, as if it cancels validation. I used the SelectedIndexChange event handler. All that I did was to add the following at the end of the event handler:
if(Page.IsPostBack)
Page.Validate();
Is this correct? Or should I do it differently?
Regards,
Brendan
|
|
|
|
|
That's correct. If you only want the page to be validated when there's a postback from the select box, then that's definitely the way to do it.
Picture a huge catholic cathedral. In it there's many people, including a gregorian monk choir. You know, those who sing beautifully. Then they start singing, in latin, as they always do: "Ad hominem..."
-Jörgen Sigvardsson
|
|
|
|
|
Hello Guys,
I have a requirement to create a windows service which will hit the database on a regular interval to check the record count of a table. This service wud be running on a remote server. When ever there is a increment in the record count, the service has to notify the user.
There wud be an application running on the client system which wud accept the message coming from the service and display it as a pop-up on the desktop. Message communication wud always be from server to client only. Server application is a windows service and the client application wud be windows forms.
I was able to create windows service which hits the DB and checks the count. I’m struck up with sending the message to the client system. I’m not sure abt using socket programming v/s Remoting to achieve this task as this is the first time I’m trying this sort of App.
So any kind of info would be of gr8 help. And thanks a lot of ur patience to read this lengthy mail
Chakri
|
|
|
|
|
It's fairly simple to do this using remoting. Host a remote object (Singleton) in your service and make it expose an event. Make the Winforms client subscribe to the event and you are ready to go. Watch out for this[^] though, might cause endless grief if you don't do it.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Senthil,
Thanks alot for ur suggestion. As i said i'm novice to C#, can you pls help me out by sending me a small working sample of the App to smartboy3k@yahoo.com
Thanks in Advance
Chakri
|
|
|
|
|
Hi All,
I am working with C# .Net Web Application. The application needs to process one large Excel file. This will take some few minutes. But before the execution is over the web page displays the message "server Application Unavilable". The same process i have tried in the high configuration machine and it was working fine but if try in a normal machine its showing this message.Can anyone plz give me a solution on this.
Thanks in Advance.
Shans.........
|
|
|
|
|
The script timeout is normally about a minute. If the page code is running longer than that, it will time out and send the error message to the browser. If you specify a longer script timeout for the page, it won't time out.
---
b { font-weight: normal; }
|
|
|
|
|
Hello:
I am currently working on little project where I have to take RichText(RTF) input, and then draw it out using GDI+. The user able to change text format in middle of the text string just like VISIO 2003. The RTF able to rotate and translate using GDI+. If anyone know about any article or code snipe that I could look at it.
Thank You.
|
|
|
|
|
Can anybody tell me about the coding concept of RS232 in C#.
Thanks
|
|
|
|
|
Could anyone please help me out as to how we can save the excel workbook in the database and read it back anytime we want.
I was able to convert the text files and image files into binary format and save them to the DB and finally able to retrive them back in the same format. But was unable to do same for the excel object.
Intellectuals solve problems; geniuses prevent them.
|
|
|
|
|
If i set the transparent colour of my form to lime green then put a custom control on my form with a lime green background is makes a "hole" in my form with the non lime elements floating in the void.
But what i want it to do is just not show the parts of that control that are lime and draw the base form behind the control where the lime overlays it. So basicly the control and control alone becomes transparent in places leaving the main form intact.
Is there a way to do this?
|
|
|
|
|
Ok after having trawled for hours before i made the above post and having caried on for over an hour i found a way of doing what i wanted
But i cant stand that i dont know why it works:
Here is the code... i can understand why you override the background painting but the other 2 methods i just dont get:
<br />
protected override void OnPaintBackground(PaintEventArgs pevent)<br />
{<br />
}<br />
protected override CreateParams CreateParams<br />
{<br />
get<br />
{<br />
CreateParams cp = base.CreateParams;<br />
cp.ExStyle |= 0x20;<br />
return cp;<br />
}<br />
}<br />
protected override void OnMove(EventArgs e)<br />
{<br />
RecreateHandle();<br />
}
If any can explain it to me that would be great
|
|
|
|
|
I'm not sure what RecreateHandle(); is pointing to for the OnMove override but it seems to me that overriding the OnPaintBackground method and not calling the original Base.OnPaintBackground should case the application to just not ever paint the background. Is that what you're wanting?
|
|
|
|
|
Thanks again but i figered out what the OnPaintBackground was doing for the program as that was my first route of enquiry when trying to pull this off.... BUT on its own it just leaves the background as a black void.... it was the two other elements that where puzzling me as they seem to make it work but i just dont know why
|
|
|
|