how to restore back up of database with query


Write down this query

Step 1: Create new database and

Step2: execute this query

RESTORE DATABASE [Medical] FROM  DISK = N’C:\Documents and Settings\Administrator\Desktop\MedicalProject\WebApplication\DatabaseBackup\dbMedi.bak’ WITH  FILE = 1,  NOUNLOAD,  STATS = 10

Advertisements

Remotelyconfigure MSSQLSERVER


Enable remote connections for SQL Server 2005 Express or SQL Server 2005 Developer Edition
You must enable remote connections for each instance of SQL Server 2005 that you want to connect to from a remote computer. To do this, follow these steps:

1. Click Start, point to Programs, point to Microsoft SQL Server 2005, point to Configuration Tools, and then click SQL Server Surface Area Configuration.
2. On the SQL Server 2005 Surface Area Configuration page, click Surface Area Configuration for Services and Connections.
3. On the Surface Area Configuration for Services and Connections page, expand Database Engine, click Remote Connections, click Local and remote connections, click the appropriate protocol to enable for your environment, and then click Apply.

Note Click OK when you receive the following message:
Changes to Connection Settings will not take effect until you restart the Database Engine service.
4. On the Surface Area Configuration for Services and Connections page, expand Database Engine, click Service, click Stop, wait until the MSSQLSERVER service stops, and then click Start to restart the MSSQLSERVER service.

Language Under Standing


Development of Computer Langugages

Computers cna utilized only when the communications  to them are very well defined. The computer languages were not         invented in the early years of computers.The computer can understand only the high and low voltage power supply which     are represented by 1 and 0.this was binary representation was known as machine language.
Basically languages have two types.

High level

Low Level

What are High Level Languages Today
In late 1950 the higher level languages were designed to have the portability from one hardware to another.
These were more english like languages that’s why program easily get to these and easy to learn for Developers
for example VC++,C,C#,VB.NEt C#.NET J#.net,Java,PHP,Fortran,Cobol,PL/I,Pascal etc. Each language has it’s own
Interpreter or compiler or both.

What are Low Level Languages Today
A low level languages is called as assembly language.these were designed in the begninning.it has just simple         instructions(set of commands) through which all the tasks are done.
these instruction were not in binary language like english words. like MOV,LOAD.But still computer was can understand     to Machine Language so that’s why that time programmer developed a translater or a converter which makes the Assembly     language to machine language

Note: Translater also known as Assembler.

But these language have a draw back that these were closely related to hardware configuration so that’s Why these         were importable not work on other hardware Means these were hardware dependent.

SO High level languages need was raise in this IT stream.

Now What are translators and Compilers,Interpreters In these languages and How There are different from each other.

Their working in these two standard languages
TRANSLOTRS
As already u known this that
Basically computers can understand only the machine language (binary code) whcih is made up of 0s and 1s.
Therefore the programs written in lower level and higher level should be converted machine code. Fo this, the     language translators are developed to convert the langaugtes into machine code and to get results.

There are three types of translators for the languages.
Assembler
Compiler
Interpreter

Assembler

This translator is used to convert the program written in low level language assembly into machine language.

Compiler
compilers are used to convert the high level language into machine language.This checks for errors in the entier
program,lists the errors and erroneous statements and converts the program into machine code. A Separate command is     used to execute the program

Interpreter
Interpreter are also used to convert high level language into machine language.This checks for errors     statement.converts the statement into machine statement is encountered or the end of the program is reached.

Difference Between
Compiler

Entire program is checked for errors and statement,lists all the erroneous statements and the rror details and         converts into machine code.

Does not stop when an erroneous statment is encountered.

Separate command is issued to execute statement.

Generally a separate editor is used ot enter the program.

Compiler resides in the main memory during the process of compilation only hence the storage is not wasted.

Only once the program is checked for errors and is converted to machine code.

Interpreter

Errors are checked statement by statement and converts into machine code and executes it.

Stops when an erroneous statment is encourtered.
Executes the statment after conveting a nonerroneous the program.

A builtin editoris available with interpreter

Interpreter should reside in main memory throughout the process of checking for errors,converting into machine code     and executing the program sturcture.

Whenever the program is executed the statement are checked for errors and are converted into machine code ,hence it         is time consuming.

DENSE RANK FUNCTION MS SQLSERVER


create table tbemp120
(empno int,ename varchar(50),eadd varchar(50),esal int,edno int)
insert tbemp120 values(66,’vinay’,’pathankot’,42000,5)
insert tbemp120 values(2,’vinay’,’pathankot’,32000,10)
insert tbemp120 values(3,’vinay’,’pathankot’,522000,30)
insert tbemp120 values(4,’vinay’,’pathankot’,522000,20)
insert tbemp120 values(5,’vinay’,’pathankot’,42000,20)
insert tbemp120 values(6,’vinay’,’pathankot’,32000,30)
insert tbemp120 values(7,’vinay’,’pathankot’,32000,30)
select ROW_NUMBER()over(order by esal)’srno’,esal,eadd,ename from tbemp120
select Dense_RANK() over (order by esal)’drank’,esal,ename ,eadd from tbemp120
select NTILE(3) over (order by esal)’grp’,esal,ename,eadd,edno from tbemp120
select *from tbemp120
delete from tbemp120 where empno=8
drop table tbemp88
select *from tbemp120 order by empno

Popup window in Web Application with asp.net c sharp


Hello Friends Today you will get a new thing which will really helpful in your life and
in programming world.
In this article  i am telling you too many things which are essential in every application
and you have need to learn these.
Step: 1 First of all as you know make a new web site With VB or C# and Prepare out
design as given below in picture

Step 2: Now Make Out a function which will use to page class and composed a
popup window with code behind method.
In which you can pass your custom message and Make good you web application too much.
———————————————————————————–
Public Sub DisplayMessage(ByVal objPage As System.Web.UI.Page, ByVal message As String)
‘Replace end of line characters with JavaScript \n newline character.
message = Replace(message, vbCrLf, “\n”)
message = Replace(message, vbCr, “\n”)
message = Replace(message, vbLf, “\n”)
message = Replace(message, “”””, “\”””)
‘Replace ugly database tags with (slightly) more meaningful text.
message = Replace(message, “[DataDirect ADO Sybase Provider]”, “Sybase Error:”)
message = Replace(message, “Native Warning code”, “Error #:”)
Dim pageType As Type = objPage.GetType()
Dim displayName As String = “displayMessage”
Dim cs As System.Web.UI.ClientScriptManager = objPage.ClientScript
If (Not cs.IsStartupScriptRegistered(pageType, displayName)) Then
Dim displayText As String = “alert(“”” & message & “””);”
cs.RegisterStartupScript(pageType, displayName, displayText, True)
End If
End Sub
————————————————————————-
Step 3: Now Friend go on page design and Double click on Submit Button and then make a new
Method which should be bool type and Make Validation on Your Page (server side)
———————————————————————————–
Private Function IsValid() As Boolean
If (TextBox1.Text = “” Or TextBox1.Text = String.Empty) Then
DisplayMessage(Page, “Please enter your name!!!”)
Return False
ElseIf (TextBox2.Text = “” Or TextBox2.Text = String.Empty) Then
DisplayMessage(Page, “Please enter your class!!!”)
Return False
ElseIf (TextBox3.Text = “” Or TextBox3.Text = String.Empty) Then
DisplayMessage(Page, “Please enter your date of birth!!!”)
Return False
ElseIf (TextBox4.Text = “” Or TextBox4.Text = String.Empty) Then
DisplayMessage(Page, “Please enter your profession!!!”)
Return False
Else
Return True
End If
End Function
————————————————————————-
Step 4: On click procedure of Submit Button Write down these lines
———————————————————————————–
If IsValid().Equals(True) Then
strName = TextBox1.Text.ToUpper()
strClass = TextBox2.Text.ToUpper()
strDob = TextBox3.Text.ToUpper()
strProfession = TextBox4.Text.ToUpper()
Response.Write(strName + “<br/>” + strClass + “<br/>” + strDob + “<br/>” + strProfession)
End If
————————————————————————-
Step 5: If you Want to Handle Exception then Make a New  Class File With this you will learn how
can we use Class file and Use of Oops.
how can make master settings in web config file for mail sending and recievning in our project or application
For this In Go into web config file and Make Appsettings and write down these master lines for application
AppSeting Section is For Unique Key Value definition in your applicaiton
If your are unable to identify this section in web config file then can take help of Image Which is
Given below
———————————————————————————–

<appSettings>

<!–this is your mail server ip address from mail will go and receive–>

<add key=”Mail_Server” value=”193.193.193.10″/>

<!–this is your company mail user name–>

<add key=”Mail_UserName” value=”demeanormc@owmnahar.com”/>

<!–this is your company mail address from mail go and receive–>

<add key=”Mail_MailFrom” value=”demeanormc@owmnahar.com”/>

<!–this is your company mail address password–>

<add key=”Mail_Password” value=”123#”/>

</appSettings>

———————————————————————————–

Step 6: Now Make a Function of boolean type in your class File Which will mail to you automaticaly whenever

Exception Happen in your project.With this help you can decrease head ache of project handling or you will have to no

need to hand over any system handler can observe and take care your application with this Wather your application

running good or not.

———————————————————————————–

Imports Microsoft.VisualBasic

‘this namespace is essential to read out web config file appsetting section reading

Imports System.Configuration.ConfigurationManager

Namespace OrientDeveloper

Public Class Class1

Public Function ProjectExceptionMail(ByVal strMessage As String, ByVal strPageName As String) As Boolean

‘Message Body

Dim ExceptionDate As String

ExceptionDate = Date.Now.ToString()

Dim MailMessage As New StringBuilder

MailMessage.Append(“<table align=’left’ cellpadding=’0′ style=’width: 100%’>”)

MailMessage.Append(“<tr>”)

MailMessage.Append(“<td colspan=’3′ style=’width: 100%; text-align: left’>”)

MailMessage.Append(“<h1 style=’color: #CC3300′>”)

MailMessage.Append(“Project Problem Notification</h1>”)

MailMessage.Append(“</td>”)

MailMessage.Append(“</tr>”)

MailMessage.Append(“<tr>”)

MailMessage.Append(“<td style=’width: 5%’>”)

MailMessage.Append(“&nbsp;”)

MailMessage.Append(“</td>”)

MailMessage.Append(“<td style=’width: 90%’>”)

MailMessage.Append(“<table cellpadding=’0′ style=’width: 100%; float: left;’>”)

MailMessage.Append(“<tr>”)

MailMessage.Append(“<td style=’width: 100%; text-align: left’>”)

MailMessage.Append(“</td>”)

MailMessage.Append(“</tr>”)

MailMessage.Append(“<tr>”)

MailMessage.Append(“<td style=’padding-left: 30px; text-align: justify; width: 100%’>”)

MailMessage.Append(“Error notification :-your project has a exception,which is given below:”)

MailMessage.Append(“<br/><span style=’text-decoration: underline;font-weight:bold;color: #0099cc’>” + strMessage + “</span>.<br/> Please do rectify to this exception as soon as possible.”)

MailMessage.Append(“<br/> Exception Date Is :<span style=’text-decoration: underline;font-weight:bold;color;#456599′>” + ExceptionDate + “</span>.”)

MailMessage.Append(“<br/> Page Name Is :<span style=’text-decoration: underline;font-weight:bold;color;#456599′>” + strPageName + “</span>.”)

MailMessage.Append(“</td>”)

MailMessage.Append(“</tr>”)

MailMessage.Append(“<tr>”)

MailMessage.Append(“<td style=’padding-left: 30px; width: 100%’>”)

MailMessage.Append(“&nbsp;”)

MailMessage.Append(“</td>”)

MailMessage.Append(“</tr>”)

MailMessage.Append(“</table>”)

‘End of Message Body

Dim MailFrom As String

Dim MailTo As String

Dim MailSubject As String

MailFrom = “demeanormc@owmnahar.com”

MailTo = “OrientDeveloper@gmail.com”

MailSubject = “Project Problem”

Dim smtp As New Net.Mail.SmtpClient(AppSettings(“Mail_Server”).ToString())

Dim NetworkCredentials As New System.Net.NetworkCredential

NetworkCredentials.UserName = AppSettings(“Mail_UserName”).ToString()

NetworkCredentials.Password = AppSettings(“Mail_Password”).ToString()

smtp.Credentials = NetworkCredentials

Dim MailData As New System.Net.Mail.MailMessage(MailFrom, MailTo, MailSubject, MailMessage.ToString())

MailData.IsBodyHtml = True

Try

smtp.Send(MailData)

Return True

Catch ex As Exception

Return False

Finally

MailData.Dispose()

End Try

End Function

End Class

End Namespace

———————————————————————————–

Step 7: Now Friends you go into code file of your page and make four line method for page exception handling and

Acces to this mail sending method.

Before this you go into source file of your presentation layer of page and make a div as given below

——————————————————————————————————————

<%@ Page Language=”VB” AutoEventWireup=”false” CodeFile=”Default.aspx.vb” Inherits=”_Default” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;

<html xmlns=”http://www.w3.org/1999/xhtml”&gt;

<head runat=”server”>

<title></title>

<style type=”text/css”>

.style1

{

width: 100%;

border: 2px solid #800000;

background-color: #eeeeee;

}

</style>

</head>

<body>

<form id=”form1″ runat=”server”>

<%–this is exception handler div–%>

<div id=”DivException” runat=”server” style=”background-color: Black; color: White;

border-color: #0099CC; font-size: medium; font-family: Helvetica; font-style: normal;

font-weight: bold;”>

</div>

<%–end of exception handler div–%>

<div>

<table cellpadding=”0″ cellspacing=”0″ class=”style1″>

<tr>

<td>

Enter Your Name

</td>

<td>

<asp:TextBox ID=”TextBox1″ runat=”server”></asp:TextBox>

</td>

<td>

&nbsp;

</td>

</tr>

<tr>

<td>

Enter Your Class

</td>

<td>

<asp:TextBox ID=”TextBox2″ runat=”server”></asp:TextBox>

</td>

<td>

&nbsp;

</td>

</tr>

<tr>

<td>

Enter Your DOB

</td>

<td>

<asp:TextBox ID=”TextBox3″ runat=”server”></asp:TextBox>

</td>

<td>

&nbsp;

</td>

</tr>

<tr>

<td>

Enter Your Profession

</td>

<td>

<asp:TextBox ID=”TextBox4″ runat=”server”></asp:TextBox>

</td>

<td>

&nbsp;

</td>

</tr>

<tr>

<td>

&nbsp;

</td>

<td>

<asp:Button ID=”Button1″ runat=”server” Text=”Submit” />

</td>

<td>

&nbsp;

</td>

</tr>

</table>

</div>

</form>

</body>

</html>

——————————————————————————————————————

Step 8: Now go into page code file and Import to class namespace and make object of your class as given below

——————————————————————————————————-

Imports OrientDeveloper

Partial Class _Default

Inherits System.Web.UI.Page

Dim objClsMail As New Class1

Dim strPageName As String

Dim strName, strClass, strDob, strProfession As String

————————————————————————————–

And  Now make this method

————————————————————————————–

Private Sub CurrentPageException(ByVal ex As String)

DivException.Attributes.Add(“display”, “block”)

DivException.InnerText = ex.Replace(ex, “Due to server problem there is error on this action,please try after some time…”)

strPageName = Request.FilePath()

objClsMail.ProjectExceptionMail(ex.ToLower(), strPageName)

End Sub

———————————————————

Step 9: Into page load write down these lines of code

———————————————————

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

If (Not (IsPostBack)) Then

DivException.Attributes.Add(“display”, “none”)

DivException.InnerText = String.Empty

End If

End Sub

———————————————————

Now On submit button click code will be as given below

——————————————————–

Try

If IsValid().Equals(True) Then

strName = TextBox1.Text.ToUpper()

strClass = TextBox2.Text.ToUpper()

strDob = TextBox3.Text.ToUpper()

strProfession = TextBox4.Text.ToUpper()

Response.Write(strName + “<br/>” + strClass + “<br/>” + strDob + “<br/>” + strProfession)

End If

Catch ex As Exception

CurrentPageException(ex.Message)

Finally

Call Refresh()

End Try

——————————————————–

Refresh method is will be as below

——————————————————-

Private Sub Refresh()

TextBox1.Text = String.Empty

TextBox2.Text = String.Empty

TextBox3.Text = String.Empty

TextBox4.Text = String.Empty

End Sub

Now Run to Your Application and Be Happy ,enjoy in this world!!!

Image Gallery For Some part of Code Clearification

Use of Microsoft Application Blocks


Step 1: First of all you will have to download MSBlocks then install to them in your system.

For what are msblocks go on this link

http://www.code-magazine.com/Article.aspx?QuickID=0411061

and you want to download to these go on this link for demo application

http://www.codeproject.com/KB/database/MS_Application_Blocks.aspx

MsBlocks are nothing just a application which composed into Asp.net and will add his refrence into your web application then can use to his method into Your web site

For example

Make a new web site and Write into page source these lines of code

<%@ Page Language=”C#” AutoEventWireup=”true”  CodeFile=”Default.aspx.cs” Inherits=”_Default” %>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;
<head runat=”server”>
<title></title>
</head>
<body>
<form id=”form1″ runat=”server”>
<div>
<asp:DataGrid ID=”DataGrid1″ runat=”server” Height=”100%” Width=”100%” HeaderStyle-BackColor=”Black” HeaderStyle-BorderStyle=”Groove” HeaderStyle-BorderWidth=”1″ HeaderStyle-Font-Bold=”true” HorizontalAlign=”Center”
AlternatingItemStyle-BackColor=”Red” AllowSorting=”true” AlternatingItemStyle-ForeColor=”White”
BackColor=”GrayText” ForeColor=”Yellow”>
<Columns >
</Columns>
</asp:DataGrid>
</div>
</form>
</body>
</html>

Step 2: now write these lines of code into code file of your page

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Data;

using System.Data.SqlClient;

using System.Configuration;

using Microsoft.ApplicationBlocks.Data;

public partial class _Default : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

try

{

DataGridBind();

}

catch(Exception ex)

{

throw ex;

}

}

private void DataGridBind()

{

//Database Connection Information

String con = (string)(ConfigurationSettings.AppSettings[“cn”]);

//Sql Statement

String qry = “select top 5 *from TbEmp”;

//Create the Connection Objec

SqlConnection sqlcon = new SqlConnection(con);

//Create Employee Dataset

DataSet Empds = SqlHelper.ExecuteDataset(con, CommandType.Text, qry);

DataGrid1.DataSource = Empds.Tables[0];

DataGrid1.DataBind();

}

}

Remember to make a tbemp table into mssqlserver
TbEmp
———-
For more code of it’s example read out to this

Introduction

Summary:

Microsoft has developed and released Application Blocks for Data Access and Exception Management for using in .NET applications. These application blocks provide the .NET developer not only the ready to use code inside the application, but also the code which was built by encapsulating the best practices by Microsoft.

In this discussion we are going to examine the following:

  • What are the advantages of Data Access Application Block?
  • How to install the Data Access Application Block?
  • Create a sample .NET application using the Data Access Application Block.

Advantages of Data Access Application Block

Microsoft has developed this wrapper on top of the ADO.NET layer by encapsulating the performance and memory management related best practices for Microsoft SQL Server. So we need not worry about the data access performance and memory leaks.

This comes as a single assembly with a class consisting of useful methods which serve all kinds data access requirements. By using these simple calls in our code, we can reduce the amount of custom code we actually write in our conventional applications. Moreover we can also skip the over head of testing and maintenance of our custom code.

Microsoft provides the source code files, along with the Quick start samples and documentation. We can use the source code as it is or we can even customize as per our application needs.

Installing the Data Access Application Block

This is a free software and you can download it from here.

The current version of this block is 2.0. And we need to have Visual Studio. NET installed on the target machine.

Your installation should create an entry in the Start > Programs > menu called �Microsoft Application Blocks for .NET�, where it will show links to source code and samples.

Sample screenshot

Fig 1: After installing the Application Block.

Select the Data Access Application Block option by navigating to the path shown in the figure. It then opens the solution in the VS.NET IDE.

Sample screenshot

Fig 2: Open the Data Access Application Block solution in the IDE.

Click on the SQLHelper.cs file to look inside the code. It creates a namespace with the nameMicrosoft.ApplicationBlocks.Data with two sealed classes SqlHelper andSqlHelperParameterCache created inside that.

Now right click on the project name and click Build. Now you should see the assembly created at the following path:

C:\Program Files\Microsoft Application Blocks for .NET\Data Access v2\Code\CS\Microsoft.ApplicationBlocks.Data\bin\Debug

So we have built the Data Access block assembly, now we create a Web Application in which we refer this assembly. In our web application, we use a simple web form to connect to SQL Server 2000 and access the data from the database.

Create a sample .NET application using Data Access Block.

Step 1: Select File > New > Project from the file menu, select the ASP.NET Web Application and enter the project name and path accordingly.

Sample screenshot

Fig 3: Creating a sample web application.

Step 2: Now we add the Data Access Block to our project. To do this, right click on the references node and click Add Reference. Click on the Browse and select the Microsoft.ApplicationBlocks.Data.dll and click Ok button.

Sample screenshot

Fig 4: Adding the Data Access Block reference.

Step 3: Open the WebForm1 and drag a datagrid from the toolbox onto it.

Sample screenshot

Fig 5: Adding the datagrid to the WebForm1.

Step 4: Add the line for using the Data Access Block assembly.

Sample screenshot

Fig 6: Using Microsoft.ApplicationBlocks.Data namespace.

Step 5: Add the following code in the Page_Load event procedure.

This code creates a connection to the SQL Server database.

We have used the ExecuteDataset static method of the SqlHelper class to fetch the top 10 records from Employees table.

Sample screenshot

Fig 7: Call SqlHelper.ExecuteDataset method

In the above code, I have used my own credentials for connecting SQL Server. Please change those accordingly.

Step 6: Run the WebForm1.aspx page in the browser to see the output.

Sample screenshot

Fig 8: Result displayed in WebForm1.aspx

Be happy and enjoy in programming World!!!

Gmail Mail Code Which is Free


MailMessage msg = new MailMessage(“abcgmail.com”, TextBox1.Text);
SmtpClient smtp = new SmtpClient();
msg.Body = TextBox3.Text;
msg.Subject = TextBox2.Text;
smtp.Host = “smtp.gmail.com”;
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.Credentials = new System.Net.NetworkCredential(“absgmail.com”, “passwd”);
smtp.Send(msg);
Response.Write(“Feedback Submitted successfully”);