|
When I don't pass certain value in textbox. It gives me above exception.
Here's the code.
cmd.Parameters.Add("DOB", SqlDbType.SmallDateTime).Value = txtDOB.Text;
I want to ignore NULL values. How to tackle this problem.
I know it should have been easy. But anyhow, I stuck .
Regards
Asif Rehman
|
|
|
|
|
If the value in txtDOB.Text is a null or whitespace character, you need to set Value to DBNull.Value .
|
|
|
|
|
thanks for quick response.
So to my best understanding, I can replace
old phrase
cmd.Parameters.Add("DOB", SqlDbType.SmallDateTime).Value = txtDOB.Text;
with this one
cmd.Parameters.Add("DOB", SqlDbType.SmallDateTime).Value = (string.IsNullOrEmpty( txtDOB.Text)) ? DBNull.Value.ToString() : txtDOB.Text;
Is there any way shorter to do this.
Regards
Asif Rehman
|
|
|
|
|
I normally use a utility method like this:
public static object GetValueForParameter(string value)
{
if (!string.IsNullOrWhitespace(value))
return value;
return DBNull.Value;
} Then you can replace your code with cmd.Parameters.Add("DOB", SqlDbType.SmallDateTime).Value = Utility.GetValueForParameter(txtDOB.Text);
|
|
|
|
|
Thanks. It works.
Regards
Asif Rehman
|
|
|
|
|
You're welcome. Thanks for letting me know.
|
|
|
|
|
hi guys,
i just developed an easy ajax enabled page. but whenever i execute an ajax script i get an error:
'Access is denied'.
this site is running on the server and accessing it from my local machine.
is there anyone who knows why my ajax calls to the server are being denied?
Please help me.
Regards,Morgs
|
|
|
|
|
|
hi guys,, i want to open a model popup extender when a row inserted to the particualar table
now i can open a model popup window manually but i want it to be done automatically if a row inserted to the table in sql server 2005
Please let me know as soon as possible
Ahamed Azeem
software Programmer
|
|
|
|
|
if u want to do it from codebehind, make your main div to runat="server" so that you can access it from codebehind.
e.g.
After the code for inserting a new row executes the very last thing u must now do is to show the modal.
e.g.
public void InsertTableRow()
{
popupModal.Style.Value = "display:block;";
}
hope that helps...
|
|
|
|
|
You can use Open() method of ModalPopupExtender in code behind when new row is added.
|
|
|
|
|
Hi,
I am developing ASP.net and VS2010; I am using MVC; I right click on Model Folder to choose an Data Model; just wondering to know what is difference between Dataset and SQLServerDatabase?
|
|
|
|
|
Dataset are inmemory objects, these are used to store data (in table form).We fetch data from the databse, fill it in databse. Now we do our manipulation in the dataset and show the results accordingly. .NET provides the facility to do most of the opertaion that we can do with database table. We use dataset , when there is low no records in resultant table.
While SQLServerDatabase, we store in database. Ther are stored in files at harddisk.Obusly we have bit more flexibility over dataset. If number of records are higher, we use databse for all the manipulation..
|
|
|
|
|
what are the advantages of .ashx pages and how can I write Html tags in ashx file?
Sample url
Page Extension is ASHX[^]
|
|
|
|
|
We used to write HTTP Handlers at certain situations in our applications. In traditional way, writing Handlers needs to several steps. To avoid these, ASP.NET provides a way to write the HTTP Handler by just using a .ashx files.
We use Handlers, to handle certain situations like, if we want to process some different file extensions,for changing themes etc..
for details, have a look to followng links..
Click here 1
Click here 2
|
|
|
|
|
ok thanks for the links.
one more doubts, how to handle click events below submit button in the .ashx page.
context.Response.Write(
"<input type=submit name='Lookup'
value='Lookup'></input>");
|
|
|
|
|
I have to say that, given the importance of validating user input against SQL Injection, XSS and the like, that someone (.. Microsoft themsleves, as a .NET class) haven't written a comprehensive class library to take care of this. Client side validation doesn't count - though having said that, the routines used for that must go some way at least towards a solution.
I know that the new .NET validation server controls can validate server-side, but they still expect the user to define (too much) in terms of pattern matching, for example. i.e., they are too complex; what is really needed is something much simpler that just returns True or False depending on whether the input is a potential threat in terms of SQL Injection or XSS. Whether they've entered the correct data in the correct field is another issue.
I know it's a tricky task, but surely not beyond the wit of one of you eggheads out there But perhaps I've missed it, and there are such libraries available...
|
|
|
|
|
Hi all
I need to validate a string to allow html or simple text but not script language means a textbox can accept bold, italic tag of html
but not script tag like alert("hi");
how can i do this
Any help would be appreciated..
Amit
|
|
|
|
|
Just check the <script tag.
if(txtBox.Text.Contains("<script")
|
|
|
|
|
It takes a bit more than that............
what about if the symbols are encoded, what about if the user puts whitespace between the symbol and the 's' there are various other things to think about.
Search Google, there are various articles relating to Validating User Input and limited HTML;
e.g.
http://www.brainhandles.com/techno-thoughts/form-validation-php-html[^]
Dave
Find Me On: Web| Facebook| Twitter| LinkedIn
CPRepWatcher now available as Packaged Chrome Extension, visit my articles for link.
|
|
|
|
|
I have developed a set of ssrs .rdl reports and am trying to display them from the reportviewer control embeded in my asp web page. The problem is that when I select the print icon on the reportviewer I am prompted to install ms sql server. I need help here. What is the best way to print .rdl reports from the web page's embeded reportviewer control to the client's local network printer?
Thanks,
Steve
|
|
|
|
|
After doing some research it appears that using the RsClientPrint ActiveX control is the way to go. Is this correct? Now if this is the best way to do what I want how would I initially install it on every client machine that is accessing my website? Any help with this would be great!. Also, is there a way to set the reportviewer print layout to legal size by default?
Thanks,
Steve Holdorf
|
|
|
|
|
Re: Just to clairfy my last post. When I said that I wanted to set the reportview print to legal size I mean portrait mode on legal size paper. Again, any help would be great!
|
|
|
|
|
I have a question..
where is codeproject.com hosted? with which company?
|
|
|
|
|
aaaaannnnndddd how is this related to ASP?
|
|
|
|