Monday, 24 August 2015

how to check store procedure exist or not

SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME="procedure name" AND ROUTINE_SCHEMA="dbname";

store processior in my sql

DELIMITER //
 create procedure duplicat(IN stName longtext,IN stmobile longtext,IN stfather longtext,IN stemail longtext)
 begin
  Select Auto_No from tblname  where Data_As_Duplicate is null  and ucase(Student_Name_AlphabetShort)=stName and (studentMobileNumber=stmobile or  lcase(studentEmailID)=stemail ) and ucase(Parent_Name_AlphabetShort)=stfather order by Auto_No ;
end//
DELIMITER ;

call duplicat('nishant', '7503485910','sdk','nishant70417@live.com')

Thursday, 13 August 2015

How to Set background color of Combobox item in vb.net


'Set the Combobox's DrawMode property to OwnerDrawVariable

    Private Sub test_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ColorName As String
        For Each ColorName In System.Enum.GetNames(GetType(System.Drawing.KnownColor))
            ComboBox1.Items.Add(Color.FromName(ColorName))
        Next
    End Sub
    'The above code will load the known color names, and then adds Color objects to the combobox's Items collection.
    'Next, let's add our MeasureItem sub ( for the combobox ) :
    Protected Sub Combobox1_MeasureItem(ByVal sender As Object, ByVal e As System.Windows.Forms.MeasureItemEventArgs) Handles ComboBox1.MeasureItem
        Dim myRandom As New Random
        e.ItemHeight = myRandom.Next(20, 20)
    End Sub
    'This, will call the overloaded Random.Next method to get the next random number between 20 and 40, and assign that to the ItemHeight property of the MeasureItemEventArgs parameter.
    'Last step, add the DrawItem event :
    Protected Sub Combobox1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles ComboBox1.DrawItem
        If e.Index < 0 Then
            e.DrawBackground()
            e.DrawFocusRectangle()
            Exit Sub
        End If
        ' Get the Color object from the Items list
        Dim CurrentColor As Color = CType(ComboBox1.Items(e.Index), Color)

        ' get a square using the bounds height
        Dim SizeRect As Rectangle = New Rectangle(2, e.Bounds.Top + 2, e.Bounds.Width, e.Bounds.Height - 2)

        Dim ComboBrush As Brush

        ' call these methods first
        e.DrawBackground()
        e.DrawFocusRectangle()

        ' change brush color if item is selected
        If e.State = Windows.Forms.DrawItemState.Selected Then
            ComboBrush = Brushes.White
        Else
            ComboBrush = Brushes.Black
        End If

        ' draw a rectangle and fill it
        e.Graphics.DrawRectangle(New Pen(CurrentColor), SizeRect)
        e.Graphics.FillRectangle(New SolidBrush(CurrentColor), SizeRect)

        ' draw a border
        SizeRect.Inflate(1, 1)
        e.Graphics.DrawRectangle(Pens.Black, SizeRect)

        ' draw the Color name
        e.Graphics.DrawString(CurrentColor.Name, ComboBox1.Font, ComboBrush, e.Bounds.Height + 5, ((e.Bounds.Height - ComboBox1.Font.Height) \ 2) + e.Bounds.Top)
    End Sub







Friday, 7 August 2015

Wednesday, 5 August 2015

MySQL Stored Procedure

DELIMITER //
CREATE PROCEDURE aff2_2015
(IN con longtext, IN mob bigint)
BEGIN
  SELECT * FROM affidavitdata_2015
  WHERE studentFirstName = con and studentmobilenumber=mob;
END //
DELIMITER ;
CALL aff2_2015('nishant','7503485910');

How create setup file in vb.net

1) Click 'File' -> 'Add' -> 'New Project'.
2) Goto 'Other Project Types' and 'Setup and Development'.
3) Choose 'Setup Project'.
4) In the 'Solution Explorer' rightclick on your setup project.
5) Choose 'Properties'.
6) Click 'Prerequisites...' button.
7) Choose your prerequisites (e.g. .NET Framework, Windows Installer).
8) Press 'OK', press 'Apply'.
9) Rightclick on 'Application Folder' in the left File System window.
10) Choose 'Add' -> 'Project Output'
11) When done, rightclick in the Right File System window.
12) Choose 'Add' and whatever you want to add to the application directory
during installation.
13) Rightclick on 'Project output from ....'
14) Select 'Create shorcut to Primary output from ...'
15) Rightclick on 'Shorcut to Primary output from...'
16) Choose 'Rename'
17) Name it after your application.
18) Select it and drag it to the left to 'User's Program Menu'.
19) (Build solution) Build your setup project.
20) In the setup project directory you'll find the .exe and .msi file to

install your application.

String Abribiation in vb.net

Function colldbabrivatename(ByVal sstring As String) As String
        sstring = Replace(sstring, "  ", "")
        sstring = Trim(sstring)
        Dim abribiatedata = Split(sstring, Space(1))
        If UBound(abribiatedata) > 0 Then
            Dim abribiateform As String = ""
            For i As Integer = LBound(abribiatedata) To UBound(abribiatedata)
                If abribiatedata(i).Substring(0, 1) = "[" Or abribiatedata(i).Substring(0, 1) = "(" Then Exit For
                If Len(abribiatedata(i)) > 1 Then
                    If abribiateform = "" Then
                        abribiateform = abribiatedata(i).Substring(0, 1)
                        abribiateform1 = abribiatedata(i).Substring(0, 1)
                    Else
                        abribiateform = abribiateform & "" & abribiatedata(i).Substring(0, 1)
                        abribiateform1 = abribiateform1 & " " & abribiatedata(i).Substring(0, 1)
                    End If
                Else
                    If abribiateform = "" Then
                        abribiateform = abribiatedata(i)
                        abribiateform1 = abribiatedata(i)
                    Else
                        abribiateform = abribiateform & "" & abribiatedata(i)
                        abribiateform1 = abribiateform1 & " " & abribiatedata(i)
                    End If
                End If
            Next
            sstring = abribiateform
        End If

        colldbabrivatename = sstring
    End Functio

sort string as alphabetical in vb.net

Function sortalphabet(ByVal wrd As String)
        sortalphabet = ""
        Dim myarr() As String
        Dim Length As Integer = Len(wrd)
        ReDim myarr(Length)
        For i = 1 To Length
            Dim charac As String = Mid(wrd, i, 1)
            myarr(i - 1) = charac
        Next
        Dim Sorted As Boolean = False
        Do While Not Sorted
            Sorted = True
            For x = 0 To UBound(myarr) - 1
                If myarr(x) > myarr(x + 1) Then
                    Dim temp As String = myarr(x + 1)
                    myarr(x + 1) = myarr(x)
                    myarr(x) = temp
                    Sorted = False
                End If
            Next
        Loop
        sortalphabet = Join(myarr, Space(0))
    End Function

Saturday, 1 August 2015

Email Send Class in Vb.net

Imports System.Net.Mail
Public Class Emailclass
    Public Function SendEmail(ByVal Recipient As String, _
                      ByVal CopyRecipients As List(Of String), _
                      ByVal FromAddress As String, _
                      ByVal Subject As String, _
                      ByVal Body As String, _
                      ByVal UserName As String, _
                      ByVal Password As String, _
                      ByVal ishtml As Boolean, _
                      ByVal ssl As Boolean, _
                      Optional ByVal Server As String = "smtp.gmail.com", _
                      Optional ByVal Port As Integer = 587, _
                      Optional ByVal Attachments As List(Of String) = Nothing, _
                      Optional ByVal ImgCnts As List(Of String) = Nothing) As Boolean

        Dim Email As New MailMessage()

        Try
            Dim SMTPServer As New SmtpClient
            For Each Attachment As String In Attachments
                Email.Attachments.Add(New Attachment(Attachment))
            Next

            Email.From = New MailAddress(FromAddress)

            Email.To.Add(Recipient)


            For Each CopyRecipient As String In CopyRecipients
                If CopyRecipient <> "" Then
                    Email.CC.Add(CopyRecipient)
                End If
            Next
            Email.Body = Body
            If ishtml = True Then
                For Each ImgCnt As String In ImgCnts
                    If ImgCnt <> "" Then
                        Dim alternateView As AlternateView = alternateView.CreateAlternateViewFromString(Body, Nothing, "text/html")
                        Dim imgpath As String = Trim(Strings.Left(ImgCnt, InStr(ImgCnt, "|") - 1))
                        'Create the LinkedResource here
                        Dim logo As New LinkedResource(imgpath, "image/jpeg")  'Content Type is set as image/jpeg
                        logo.ContentId = Trim(Mid(ImgCnt, InStr(ImgCnt, "|") + 1))
                        logo.TransferEncoding = Net.Mime.TransferEncoding.Base64

                        alternateView.LinkedResources.Add(logo)
                        Email.AlternateViews.Add(alternateView)
                    End If
                Next
            End If
            Email.Subject = Subject
            Email.IsBodyHtml = ishtml
            SMTPServer.Host = Server
            SMTPServer.Port = Port

            SMTPServer.Credentials = New System.Net.NetworkCredential(UserName, Password)

            SMTPServer.EnableSsl = ssl
            SMTPServer.Send(Email)
            MessageBox.Show("email sent successfully")
            Email.Dispose()

            Return True

        Catch ex As SmtpException

            Email.Dispose()
            Return False

        Catch ex As ArgumentOutOfRangeException

            Email.Dispose()
            Return False

        Catch Ex As InvalidOperationException

            Email.Dispose()
            Return False
        End Try
    End Function

End Class

Validate Email in Vb.net

Public Function ValidateEmail(ByVal strEmail As String) As Boolean
        Dim strtmp As String, n As Long, sExt As String
        ValidateEmail = True

        If strEmail = "" Then
            ValidateEmail = False
            Exit Function
        ElseIf strEmail.ToLower.Contains("error") Then
            ValidateEmail = False
            Exit Function
        ElseIf strEmail.ToLower.Contains("eror") Then
            ValidateEmail = False
            Exit Function
        ElseIf strEmail.ToLower.Contains("websit") Then
            ValidateEmail = False
            Exit Function
        ElseIf strEmail.ToLower.Contains("webside") Then
            ValidateEmail = False
            Exit Function
        ElseIf strEmail.ToLower.Contains("webste") Then
            ValidateEmail = False
            Exit Function
        ElseIf strEmail.ToLower.Contains("webite") Then
            ValidateEmail = False
            Exit Function


        ElseIf strEmail.ToLower.Contains("wqebsite") Then
            ValidateEmail = False
            Exit Function


        ElseIf strEmail.ToLower.Contains("ebsite") Then
            ValidateEmail = False
            Exit Function

        ElseIf strEmail.ToLower.Contains("wesid") Then
            ValidateEmail = False
            Exit Function

        ElseIf strEmail.ToLower.Contains("wewbsite") Then
            ValidateEmail = False
            Exit Function

        ElseIf strEmail.ToLower.Contains("websitw") Then
            ValidateEmail = False
            Exit Function

        ElseIf strEmail.ToLower.Contains("websive") Then
            ValidateEmail = False
            Exit Function


        ElseIf strEmail.ToLower.Contains("websitw") Then
            ValidateEmail = False
            Exit Function
        ElseIf strEmail.ToLower.Contains("webit") Then
            ValidateEmail = False
            Exit Function
        ElseIf strEmail.ToLower.Contains("websi") Then
            ValidateEmail = False
            Exit Function


        ElseIf InStr(1, strEmail, "@") = 0 Then
            ValidateEmail = False
            Exit Function
        ElseIf InStr(1, strEmail, "@") = 1 Then
            ValidateEmail = False
            Exit Function
        ElseIf InStr(1, strEmail, "@") = Len(strEmail) Then
            ValidateEmail = False
            Exit Function
        ElseIf InStr(InStr(1, strEmail, "@") + 1, strEmail, "@") > 0 Then
            ValidateEmail = False
            Exit Function
        ElseIf InStr(1, strEmail, "@.") > 0 Then
            ValidateEmail = False
            Exit Function
        ElseIf Len(strEmail) < 6 Then
            ValidateEmail = False
            Exit Function
        End If
        sExt = ""
        If InStr(InStr(1, strEmail, "@"), strEmail, ".") <> 0 Then
            sExt = Right(strEmail, Len(strEmail) - InStr(InStr(1, strEmail, "@"), strEmail, "."))
        End If
        If sExt = "" Then
            ValidateEmail = False
            Exit Function
        End If

        strtmp = strEmail
        While InStr(1, strtmp, "@") <> 0
            n = 1
            strtmp = Right(strtmp, Len(strtmp) - InStr(1, strtmp, "@"))
        End While
        If n > 1 Then
            ValidateEmail = False
        End If
    End Function

Email Validation check from regex code in vb.net

Imports System.Text.RegularExpressions ' add name space
    Function EmailAddressCheck(ByVal emailAddress As String) As Boolean
        Dim pattern As String = "^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]" & _
        "*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"
        Dim emailAddressMatch As Match = Regex.Match(emailAddress, pattern)
        If emailAddressMatch.Success Then
            EmailAddressCheck = True

        Else
            EmailAddressCheck = False

        End If
    End Function