very helpful link i found on internet http://csharpdotnetfreak.blogspot.com/2008/12/export-gridview-to-pdf-using-itextsharp.html
Uncategorized
how to send mail smtp with authentication with web.mail class
hi i used following code
MailMessage message = new MailMessage();
message.To = "myemailaccount@yahoo.com";
message.From = "myemailaccount@thecrystalrosary.com";
message.Subject = "Testing Internet SmtpMail";
message.BodyFormat = MailFormat.Html;
message.Body = "body";
message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", "smtp.thecrystalrosary.com");
message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 25);
message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", 2); //2 to send using SMTP over the network
message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1); //1 = basic authentication
message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "username");
message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password");
try
{
SmtpMail.Send(message);
}
catch (Exception e)
{
// trap here
}
Hardwork Helps
how to get oracle sequence numbers in .net
hi the main Query to get sequence number is follow
select JOB_ID_SEQ.NEXTVAL from dual;
i get the required Sequence number value form following method
public int GetOracleSequenceValue(string _SequenceValue)
{
OdbcCommand _command = new OdbcCommand();
int _ItemValue = -1;
OdbcConnection _con = new OdbcConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["RCConnectionString"].ToString());
try
{
_con.Open();
_command.Connection = _con;
string _QueryString = "select "+ _SequenceValue +" from dual ";
_command.CommandText = _QueryString;
_ItemValue = Convert.ToInt32(_command.ExecuteScalar().ToString());
_con.Close();
}
catch (Exception ex)
{
Util.LogErrorToFile(ex, "MYExecuteNonQuery", "error");
}
finally
{
_con.Close();
}
return _ItemValue;
}
Chears
regular expression for email address validation
hi use this regular expression for email address validation
^[A-Za-z0-9](([_.-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([.-]?[a-zA-Z0-9]+)*).([A-Za-z]{2,})$
Regular expression validator in asp.net would be like
Chears…
How to resize image in .net
use follwing Code change image path at load event method for downloading Code
Imports System
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Drawing.Drawing2D
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim WorkingDirectory As String = "c:AliPicture"
'create a image object containing a verticel photograph
Dim imgPhotoVert As Image = Image.FromFile(WorkingDirectory + "pravs-j-the-first-step.jpg")
Dim imgPhoto As Image = Nothing
imgPhoto = FixedSize(imgPhotoVert, 100, 100)
imgPhoto.Save(WorkingDirectory + "imageresize_3.jpg", ImageFormat.Jpeg)
imgPhoto.Dispose()
End Sub
Private Shared Function FixedSize(ByVal imgPhoto As Image, ByVal Width As Integer, ByVal Height As Integer) As Image
Dim sourceWidth As Integer = imgPhoto.Width
Dim sourceHeight As Integer = imgPhoto.Height
Dim sourceX As Integer = 0
Dim sourceY As Integer = 0
Dim destX As Integer = 0
Dim destY As Integer = 0
Dim nPercent As Single = 0
Dim nPercentW As Single = 0
Dim nPercentH As Single = 0
nPercentW = (CSng(Width) / CSng(sourceWidth))
nPercentH = (CSng(Height) / CSng(sourceHeight))
'if we have to pad the height pad both the top and the bottom
'with the difference between the scaled height and the desired height
If nPercentH < nPercentW Then
nPercent = nPercentH
destX = CInt(((Width - (sourceWidth * nPercent)) / 2))
Else
nPercent = nPercentW
destY = CInt(((Height - (sourceHeight * nPercent)) / 2))
End If
Dim destWidth As Integer = CInt((sourceWidth * nPercent))
Dim destHeight As Integer = CInt((sourceHeight * nPercent))
Dim bmPhoto As New Bitmap(Width, Height, PixelFormat.Format24bppRgb)
bmPhoto.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution)
Dim grPhoto As Graphics = Graphics.FromImage(bmPhoto)
grPhoto.Clear(Color.Red)
grPhoto.InterpolationMode = InterpolationMode.HighQualityBicubic
grPhoto.DrawImage(imgPhoto, New Rectangle(destX, destY, destWidth, destHeight), New Rectangle(sourceX, sourceY, sourceWidth, sourceHeight), GraphicsUnit.Pixel)
grPhoto.Dispose()
Return bmPhoto
End Function
End Class
Pl Sql Built in Functions
hi find these build in function for orcale pl sql , These are really usefull
| Function | Description |
| String Functions | |
| upper(s), lower(s) | convert string s to upper/lower-case |
| initcap(s) | capitalise first letter of each word |
| ltrim(s), rtrim(s) | remove blank char. from left/right |
| substr(s,start,len) | sub-string of length len from positionstart |
| length(s) | length of s |
| Date Functions | |
| sysdate | current date (on Oracle server) |
| to_date(date, format) | date formatting |
| Number Functions | |
| round(x) | round real number x to integer |
| mod(n,p) | n modulus p |
| abs(x) | absolute value of x |
| dbms_random.random() | generate a random integer |
| Type Conversion Functions | |
| to_char() | convert to string |
| to_date() | convert to date |
| to_number() | convert to number |
| Miscellaneous Functions | |
| user | current Oracle user |
Composition and Aggregation in oops
Composition and Aggregation are basically whole/part relationship.
When the lifetime of the part is dependent on or controlled by the whole, the relationship between the whole and part is Composition.
Which simply means that the part is no more existing when the whole is destroyed.
example : car and engine.
Aggregation :
When the lifetime of the part is not dependent on or not controlled by the whole, the relationship between the whole and part is Aggregation.
Which simply means that the part continues to exist when the whole is destroyed.
example : car and stereo
So this typically it means that the part should be shared across multiple objects.
So if one object is destroyed , still the part is continued to be used by other objects
Association :
Association is simply “uses” relation ship .
It is achieved by simple references in Java.
Point to note is that Aggregation is a special case of Association . OR other way to say is that Aggregation can be achieved by using Association.
how to insert dateTime in Oracle database using c#
hi all, i have facing problem while Executing Insert query with dataTime on Oracle database. This query is generated by string manuplation using C# at business layer . i fix the date time as in Query
"TO_DATE('" + ProdMonitor.TRANSACTIONDATE.Month+
"/" + ProdMonitor.TRANSACTIONDATE.Day +
"/" + ProdMonitor.TRANSACTIONDATE.Year+
" " + ProdMonitor.TRANSACTIONDATE.ToLongTimeString()+
"','mm/dd/yyyy HH:MI:SS PM'),"
The Whole Query Will be like
Insert Into JOBS (JOB_ID , EXECUTION_TIME,CREATION_TIME,SERIAL_NO,STATUS) values(JOB_ID_SEQ.NEXTVAL,TO_DATE('9/29/2008 11:00:00 PM','mm/dd/yyyy HH:MI:SS PM'),TO_DATE('9/26/2008 12:59:59 PM','mm/dd/yyyy HH:MI:SS PM'),'','1')
Chears
update statement with select in teradata
hi all, i use following syntex for this
UPDATE T1 FROM (SELECT t2_1, MIN(t2_2) from T2 group by 1) as D (D1, D2)
SET Field2 = D2
WHERE Field1 = D1
So i solve my problem as
UPDATE XTZ.KPI FROM (SELECT CONVERTED_TARGET_QTY,NORMAL_VALUE,CRITICAL_VALUE FROM DP_UTL.PRODUCTION_KPI WHERE PACKAGE='SSPET-500') AS D(D1,D2,D3) SET
MaximumValue = D1
, NormalValue = D2
, CriticalValue = D3
WHERE KPIId=125;
Chears
