Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 02, 2007 07:19 AM by natasha_arriell
Member
698 Points
343 Posts
Nov 16, 2006 04:21 AM|LINK
Contributor
6572 Points
1432 Posts
Nov 16, 2006 04:48 AM|LINK
good good, keep it up.
cheers [:)]
satish.
Nov 16, 2006 05:32 AM|LINK
can u give me some samples on how can i generate an error trap?
example my datatype is int of type 2.
and ofcourse i cant input characters or syembols or numbers greater than 3...
coz im error trapping about time and minutes....
Nov 16, 2006 05:53 AM|LINK
well,
i suggest you to use validators or validation before sending data to database.
you can put your code in try catch blocks always a better practise
try{}
catch(SQLException ex){//for db exceptions}
catch(Exception ex){//general exception}
finally{}.
alternatively if you are using stored procedure you can check if error occured using
if @@Error
Begin
//return -1 etc @@Error is positive if an error occured.
End
will that help you ?
regards,
Nov 16, 2006 06:05 AM|LINK
try catch block? hmmmm sorry i dont know how to use it....
sorry can u explain further what it is.... or give simple example on how to use it?
please:-)
Nov 16, 2006 06:24 AM|LINK
hi
use try catch similar to following
======================
SqlConnection sq;
SqlCommand sc;
{
SqlConnection sq =
SqlCommand sc =
SqlDataReader sdr = sc.ExecuteReader();
}
Console.Write(sqlex.Message+"|"+sqlex.Source+"|"+sqlex.StackTrace)
Console.Write(ex.Message+"|"+ex.Source+"|"+ex.StackTrace);
sc.Dispose();
sq.Close();
sq.Dispose();
==============
try catch basically is used to put your code in better way in that suppose some exception occurs then it will be handled in better way rather than throwing user out. if any exception occurs then its caught & then code after that runs continuosly.
hope it answers your query [:$]
Nov 16, 2006 06:47 AM|LINK
thank you.... ill try it! but ill covert it first to VB.net[:$]
hope i get it right[:)]
hey sorry for disturbing you alot!
have patience with me ok?:-)
thnx
Nov 16, 2006 06:53 AM|LINK
no problem no need to be sorry, like i said i like this forum n helping others .
Nov 20, 2006 04:46 AM|LINK
remember i ask u about data grid before?
its working already thanks...
but i have other problem again...
hmmm
example i have many columns in my datgrid
|year|Month|day|day |Name|
what i want is to combine year,monthand day in one column.
In the datagrid the the three column should be shown in the datagrid as one only.
what do u thinkshould I do?got some idea?thanks
grace
Nov 20, 2006 05:04 AM|LINK
hi,
you can directly fetch it from database as a single column like
select cast(year as varchar)+'-'+cast(month as varchar)+'-'+cast(day as varchar) from your_table
natasha_arri...
Member
698 Points
343 Posts
Re: update values...
Nov 16, 2006 04:21 AM|LINK
satish_nagde...
Contributor
6572 Points
1432 Posts
Re: update values...
Nov 16, 2006 04:48 AM|LINK
good good, keep it up.
cheers [:)]
satish.
natasha_arri...
Member
698 Points
343 Posts
Re: update values...
Nov 16, 2006 05:32 AM|LINK
can u give me some samples on how can i generate an error trap?
example my datatype is int of type 2.
and ofcourse i cant input characters or syembols or numbers greater than 3...
coz im error trapping about time and minutes....
satish_nagde...
Contributor
6572 Points
1432 Posts
Re: update values...
Nov 16, 2006 05:53 AM|LINK
well,
i suggest you to use validators or validation before sending data to database.
you can put your code in try catch blocks always a better practise
try{}
catch(SQLException ex){//for db exceptions}
catch(Exception ex){//general exception}
finally{}.
alternatively if you are using stored procedure you can check if error occured using
if @@Error
Begin
//return -1 etc @@Error is positive if an error occured.
End
will that help you ?
regards,
satish.
natasha_arri...
Member
698 Points
343 Posts
Re: update values...
Nov 16, 2006 06:05 AM|LINK
try catch block? hmmmm sorry i dont know how to use it....
sorry can u explain further what it is.... or give simple example on how to use it?
please:-)
satish_nagde...
Contributor
6572 Points
1432 Posts
Re: update values...
Nov 16, 2006 06:24 AM|LINK
hi
use try catch similar to following
======================
SqlConnection sq;
SqlCommand sc;
try{
SqlConnection sq =
new SqlConnection("server=someserver;initial catalog=pubs;uid='sa';password='somepassword'");SqlCommand sc =
new SqlCommand("select * from invalidtable",sq);SqlDataReader sdr = sc.ExecuteReader();
}
catch(SqlException sqlex){
Console.Write(sqlex.Message+"|"+sqlex.Source+"|"+sqlex.StackTrace)
}
catch(Exception ex){
//you could write these messages to some log file also or directly Response.WriteConsole.Write(ex.Message+"|"+ex.Source+"|"+ex.StackTrace);
}
finally{
//cleanup here.sc.Dispose();
sq.Close();
sq.Dispose();
}
==============
try catch basically is used to put your code in better way in that suppose some exception occurs then it will be handled in better way rather than throwing user out. if any exception occurs then its caught & then code after that runs continuosly.
hope it answers your query [:$]
regards,
satish.
natasha_arri...
Member
698 Points
343 Posts
Re: update values...
Nov 16, 2006 06:47 AM|LINK
thank you.... ill try it! but ill covert it first to VB.net[:$]
hope i get it right[:)]
hey sorry for disturbing you alot!
have patience with me ok?:-)
thnx
satish_nagde...
Contributor
6572 Points
1432 Posts
Re: update values...
Nov 16, 2006 06:53 AM|LINK
no problem no need to be sorry, like i said i like this forum n helping others .
regards,
satish.
natasha_arri...
Member
698 Points
343 Posts
datagrid concern....
Nov 20, 2006 04:46 AM|LINK
remember i ask u about data grid before?
its working already thanks...
but i have other problem again...
hmmm
example i have many columns in my datgrid
|year|Month|day|day |Name|
what i want is to combine year,monthand day in one column.
In the datagrid the the three column should be shown in the datagrid as one only.
what do u thinkshould I do?got some idea?thanks
thnx
grace
satish_nagde...
Contributor
6572 Points
1432 Posts
Re: datagrid concern....
Nov 20, 2006 05:04 AM|LINK
hi,
you can directly fetch it from database as a single column like
select cast(year as varchar)+'-'+cast(month as varchar)+'-'+cast(day as varchar) from your_table
regards,
satish.