Showing posts with label checking. Show all posts
Showing posts with label checking. Show all posts

Monday, March 26, 2012

performing error check on date values entered in a textbox

If you perform "Convert. ToDateTime" to the text of a textbox, the syntax should be yyyy-mm-dd. What is the syntax for performing a checking condition (so that I can output an error note if the values in the textbox are wrong rather than the whole server error screen appearing) such that I can check that the month doesn't exceed 12 and the day doesn't exceed 31 because a code such as: label1.text = Convert.ToDateTime(textbox1.text) would produce an error if the month exceeds 12 or the day exceeds 31. Thanks for the help.Why not use one of the Validator controls? There is a DataType check that can be applied to the CompareValidator (as I recall). I am not sure what it would do with yyyy-mm-dd (unless that is the format set up in regional settings) but in a pinch, you can do a custom validator...
Use the compareValidator, and set the Type to Date (making sure you also set the 'Control to Validate' property).

If you really really really want to do it in code (which is not advisable, but I have had to do it once or twice), then here is a little function I got from somebody:


Public Function IsDateValid(ByVal strDate As String) As Boolean
Try
' attempt parse
Dim dtParsed As DateTime = DateTime.Parse(strDate)
Return True
Catch ' parse failed
End Try
Return False
End Function

IsDateValid("200323") returns false
IsDateValid("20/12/2004") returns true

Not sure if it will work with yyyy-mm-dd, but try and and let us know.

HTH

Jagdip

Saturday, March 24, 2012

permission denied on object sp_sdidebug

Hi, whenever I attach the asp_net to a web site, checking 3 boxes aspnet,
t-SQL and scripting in the dialog box, run the web site, I get te following
error in spite of the fact I am logged as an administrator and the tyhe
connectionn string has trusted conn.:
SqlException: EXECUTE permission denied on object 'sp_sdidebug', database
'master', owner 'dbo'.]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +742
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +195
Thanks for your helpHi,
are you using Windows authentication or SQL Server authentication for
conecting to the DB. Or may be grant execute rights to the user through whic
h
you are loggin into in SQL Server.
HTH.
Kaustav Neogy.
"SalamElias" wrote:

> Hi, whenever I attach the asp_net to a web site, checking 3 boxes aspnet,
> t-SQL and scripting in the dialog box, run the web site, I get te followin
g
> error in spite of the fact I am logged as an administrator and the tyhe
> connectionn string has trusted conn.:
> SqlException: EXECUTE permission denied on object 'sp_sdidebug', database
> 'master', owner 'dbo'.]
> System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
> cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +742
> System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +195
> Thanks for your help
Hi SalamElias,
I think Kaustav's suggestion on checking the SQL db's security setting is
resonable. From the error info you provided, your program failed when try
to call a store procedure in the sql db. As Kaustav has said, you should
grant the proper permissions to the account you used to connect the sql db.
IF using Sqlserver authentication, that's the account you specify in the
connectionstring, if windows authentication, that'll be your asp.net
applications process identity if you 're not using impersonate.
Please feel free to let me know if you have anything unclear or there is
anything else we haven't quite understand well. Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

permission denied on object sp_sdidebug

Hi, whenever I attach the asp_net to a web site, checking 3 boxes aspnet,
t-SQL and scripting in the dialog box, run the web site, I get te following
error in spite of the fact I am logged as an administrator and the tyhe
connectionn string has trusted conn.:
SqlException: EXECUTE permission denied on object 'sp_sdidebug', database
'master', owner 'dbo'.]
System.Data.SqlClient.SqlCommand.ExecuteReader(Com mandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +742
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +195

Thanks for your helpHi,

are you using Windows authentication or SQL Server authentication for
conecting to the DB. Or may be grant execute rights to the user through which
you are loggin into in SQL Server.

HTH.

Kaustav Neogy.

"SalamElias" wrote:

> Hi, whenever I attach the asp_net to a web site, checking 3 boxes aspnet,
> t-SQL and scripting in the dialog box, run the web site, I get te following
> error in spite of the fact I am logged as an administrator and the tyhe
> connectionn string has trusted conn.:
> SqlException: EXECUTE permission denied on object 'sp_sdidebug', database
> 'master', owner 'dbo'.]
> System.Data.SqlClient.SqlCommand.ExecuteReader(Com mandBehavior
> cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +742
> System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +195
> Thanks for your help
Hi SalamElias,

I think Kaustav's suggestion on checking the SQL db's security setting is
resonable. From the error info you provided, your program failed when try
to call a store procedure in the sql db. As Kaustav has said, you should
grant the proper permissions to the account you used to connect the sql db.
IF using Sqlserver authentication, that's the account you specify in the
connectionstring, if windows authentication, that'll be your asp.net
applications process identity if you 're not using impersonate.
Please feel free to let me know if you have anything unclear or there is
anything else we haven't quite understand well. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)