Sunday 21 December 2014

Create Sql Function To Calculate Total Salary of Employee Based on Present Day in particular Month


--Function
create function dbo.funemp
(
@eid bigint,@name varchar(300),@sal float,@no_Of_day int,@month varchar(100))
returns float as
begin
declare @avgSal float
set @avgSal=(@sal/@month)*@no_of_day
return @avgSal  
end
==============

Table


CREATE TABLE [dbo].[emp](
[Eid] [int] NOT NULL,
[Name] [varchar](30) NULL,
[Salary] [int] NULL,
[No_of_day] [int] NULL,
[MonthOfYear] [varchar](200) NULL,
)
==========
Query To Display Calculated Record Of Employee
--
select *,dbo.funemp(eid,name,salary,no_of_day,Monthofyear) as 'Total Salary' from emp

Monday 18 August 2014

To delete selected Row by Key Down in GridView



private sub Grid1_keyDown()
if e.keycode=keys.Delete then

For Each row as DataGridViewRow in Grid1.SelectedRows
Grid1.Rows.Remove(row)
Next

end if

Tuesday 12 August 2014

Open PDF file by Clicking Link Button using ASP.NET

protected sub LInk_click()
Dim pdfPath As String = Server.MapPath("~/AM54640303_2014-05-12_18-51-10.pdf")
        Dim client As New WebClient()
        Dim buffer As [Byte]() = client.DownloadData(pdfPath)
        Response.ContentType = "application/pdf"
        Response.AddHeader("content-length", buffer.Length.ToString())
        Response.BinaryWrite(buffer)

end sub


--"pdf file should be present in solution explorer."

Open Word file by clicking link button in ASP.NET

 Protected Sub ll_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ll.Click
        Response.Clear()
        Response.ContentType = "application/doc"
        Response.AddHeader("content-disposition", "attachment;filename=1.doc")
        Response.TransmitFile("1.doc")
        Response.End()
    End Sub


''1.doc" should be present in solution explorer of VS

Friday 20 June 2014

Delete Duplicates Row in SQL SERVER

DELETE FROM table WHERE col1 IN (
    SELECT id FROM table GROUP BY id HAVING ( COUNT(col1) > 1 )
)

Tuesday 10 June 2014

Shatrughana Kumar Gupta: DateTime Formating Using VB.NET

Shatrughana Kumar Gupta: DateTime Formating Using VB.NET:  Dim str As String = "2014-06-10 17:41:38.760"         Dim str1 As Date = Convert.ToDateTime(str)         Dim strres As String ...

DateTime Formating Using VB.NET

 Dim str As String = "2014-06-10 17:41:38.760"
        Dim str1 As Date = Convert.ToDateTime(str)
        Dim strres As String = Format(str1, "yyyy-MMM-dd hh:mm:ss")


result : 2014-Jun-10 05:41:38

Followers