Skip to main content

Posts

Showing posts with the label .net tips and trick

Platform Independence of .NET Platform,Advantage,Disadvantages

Platform Independence of .NET Platform Its lang independent as long as that language's compiler targets the managed environment.. i.e, code written in C#.net or VB.Net or any other .Net compliant language will result in the same IL. certainly .net doesn't compile in UNIX. No compilers til date i suppose.. Heard that something similar exists to compile .net in Linux tho'.. Platform Independent does not mean O S independence in .NET terms. It means you can build a managed code and be assured it works on 32 - bit m/c, 64 bit m/c etc. Of course, at present it only supports Windows as O S, but Microsoft has left open the UNIX ( or any other O S for that matter) implementation of .NET run time. Lot of open source projects are going on in this regard. Advantages of asp with c sharp over asp with vb.net ultimately both copies in to MSIL, it depends on what application designing and what is the background of the developers who work for. C# more structured and fully OOP e...

C Sharp code for encription and decription of password or text

C# code of encription and decription following are two functions. one for encryption and second for decryption. textbox3 is text box to input data and textbox4 is textbox shows encrypted data. private void encrypt() { int i = 0; string result = ""; string old = textBox3.Text; do { result = result + Convert.ToChar(Convert.ToInt32(old) + (i + 2)); i = i + 1; } while (i < old.Length); textBox4.Text = result; textBox3.Text =""; } private void decrypt() { int i = 0; string result = ""; string old = textBox4.Text; do { result = result + Convert.ToChar(Convert.ToInt32(old) - (i + 2)); i = i + 1; } while (i < old.Length); textBox3.Text = result; textBox4,Text=""; }

SQL Tips-Search string in stored procedures of SQL,Sending Email

You can write following way to Search string in stored procedures of SQL. Syscomments and sysobject are sql system table. Sysobject table stored all object of sql like stored procedure,table name etc. declare @SearchStr      varchar(100) set @searchstr = 'String to search for' SELECT DISTINCT USER_NAME(o.uid) + '.' + OBJECT_NAME(c.id) AS 'Object name' FROM  syscomments c       INNER JOIN       sysobjects o       ON c.id = o.id WHERE c.text LIKE '%' + @SearchStr + '%'  and       encrypted = 0 I hope you will able to understand this SP. Sending mail through SQL Stored proceduare You can write following sql script in stored procedure to Send mail through SQL Stored procedure. @SenderNm varchar(100), @Senderemail varchar(100), @RecipientNm varchar(100), @Recipientemail varchar(100), @Subject varchar(200), @Body varchar(8000)...

code to disable ctrl+alt+del key using .net

code to disable ctrl+alt+del key using .net Use this code in .net for disable A-C-D Dim regkey As Microsoft.Win32.RegistryKey Dim subkey As String subkey = "Software\Microsoft\Windows\CurrentVersion\Policies\System" regkey = My.Computer.Registry.CurrentUser.CreateSubKey(subkey, Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree) regkey.SetValue("DisableTaskMgr", 0) To Again enable A-C-D use this subkey = "Software\Microsoft\Windows\CurrentVersion\Policies\System" regkey = My.Computer.Registry.CurrentUser.CreateSubKey(subkey, Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree) regkey.SetValue("DisableTaskMgr", 1) after this Restart PC and use this Function Public Sub RestartComputer() Dim t As Single Dim objWMIService, objComputer As Object 'Now get some privileges objWMIService = GetObject("Winmgmts:{impersonationLevel=impersonate,(Debug,Shutdown)}") For Each objC...

How to use interfaces in dotnet

How to use interfaces in  .Net An interfaces contains only the signatures of methods.The implementation of the methods is done in the class that implements the interface. SYNTAX: interface interface_name { void method1() void method2() } By default all the methods in interfaces are fully "public abstract" Example: ======= interface inter1 { void getdata(); void putdata(); } class sample1:inter1 { int eno; string ename; { public void getdata() { console.writeline("enter employee number"); eno=int.parse(console.readline()); console.writeline("enter employee name"); ename=console.readline(); } public void putdata() { console.writeline("employee number:"+eno); console.writeline("employee name:"+ename); } } class class1 { static void main () { sample1 obj=new sample1(); obj.getdata(); console,.writeline(); obj.putdata(); } ...

Vb.Net Code to get Financial Year

Function GETFINYR(ByVal strDate) Dim strDt, strenddt, strstdt Dim strdd, strmm, stryy, strst_dt, strend_dt Dim date1, enddate, startdate strDt = Split(strDate, "/") strdd = strDt(0) strmm = strDt(1) stryy = strDt(2) If Right(stryy, 2) = "99" Then strend_dt = "31/03/" & Left(stryy, 2) + 1 & "00" Else If Right(stryy, 1) <> "9" Then strend_dt = "31/03/" & Left(stryy, 3) & Right(stryy, 1) + 1 Else strend_dt = "31/03/" & Left(stryy, 2) & Right(stryy, 2) + 1 End If End If strenddt = Split(strend_dt, "/") strst_dt = "01/04/" & stryy strstdt = Split(strst_dt, "/") date1 = CDate(CInt(stryy) & "/" & CInt(strmm) & "/" & CInt(strdd)) enddate = CDate(CInt(strenddt(2)) & "/" & CInt(strenddt(1)) & "/" & CInt(strenddt(0))) startdat...

Search Record in Grid Using Vb.Net Code

Search Record in Grid Using Vb.Net Code If intOldcnt <= IntTblCount - 1 Then dgMain.UnSelect(intOldcnt) End If Dim inti As Integer If strToSearch.Trim <> "" Then For inti = 0 To IntTblCount - 1 If Convert.ToString(dgMain.Item(inti, 0)).Trim.ToUpper Like strToSearch.Trim.ToUpper & "*" Then If blnFlag = True Then dgMain.Select(inti) IntCount += 1 End If dgMain.CurrentRowIndex = inti intOldcnt = inti txtSearch.Focus() Exit For End If Next End If