In This blog i have to write the Most Ask interview Question for Dot Net Developer.================================================== General ================================================== 1)Tell me about yorself 2)current project description/flow 3)SDLC(Software,Development life cycle) 4)Design Pattern(creational(IOC,factory pattern,singleton),structural,behvioural) 5)Dependency Injection(IOC Pattern,DI principle, IOC Container) 6)SSIS(sql server Integrated services),SSAS(sql server Analytic services),SSRS(sql server Reporting services)(sql Server BI Studio to create project) 7)web services 8)web api/REST 9)WCF(webservies, Remoting, into one umbrala,support multiple proctocals HTTP,TCP,IPC,UDP..) 10)Unit Testing(AAA-Arrange,Act,Assert)/whitebox/Mstest project/Test Classes and Test Methods 11)Project Estimation(use Function Point)/Past Experience 12)Tickting tool(Scrum,Kanban)(JIRA,Service Now) 13)Mange Versioing (Team foundation,SVN,Source Safe) 14)Change set in Team foundation 15)how to deploy patch using TFS.(GIT hub Repository public)
16)Project task Estimation Techniques
17)BitBucket Repository(Private,public)
18)Microservices(it's Design pattern)19)About Dot Net core
================================================== OOPS ================================================== 1)concepts of OOPS (Abstratction,Encapsulation,Polymorphism,Inharitance). 2)Diffrence between Abstratction vs Encapsulation. 3)Abstract class and Interface 4)Default access modifier of calss(Private) 5)Static keyword,static class, static constructor 6)without create object how to access the method(using static class,Inharitance) 7)managed and unmanged code/how to clear unmanged space(gc.collect) 8)overloading and overriding with example 9)Arry and Arrylist 10)virtual keyword and method/overried 11)sealde class 12)why multiple inharitance is not support in C# 13)Constructor and Distructor(~ befor name)
14)Shadowing(Method hiding)
================================================== ASP.NET and C# ================================================== 1)Var and Dynamic keyword 2)Constant and Readonly 3)try,catch,finaly/Multiple catch 4)parse,tryparse 5)Gridview row color set as per condition(rowdatabound for loop and set row background and fore color) 6)ASP.Net Page life cycle 7)session mangement/varialble 8)Access modifier(public,Private,protected,Internal,Protected Internal) 9)Generic/Generic collaction/Hastable/Dictonary 10)Delegates 11)OUT vs Ref parameters 12)ADO.Net object(Dataset,datareder,dataadpter,command) 13)IEnumarable(easy syntax) and IEnumarate(hold the current state) 14)CTS,CLS,CLR,MSIL,JIT 15)typs of validation control(requiredfield,rangevalidatior,campare,custom,validtion summary) 16)exception Handaling 17)IEnurable and IQueryable
18)State Management in Asp.net
19)Caching in Asp.net
20)Authentication and Authorization
21)Asp.net Page life cycle(initialization,loading,rendering,unloading)
22)Asp.net page life cycle events
23)Session Maintenance Method(inproc[inMemeory],outproc[state server,sql server.custom])
24)Navigation Techniques in Asp.Net
25)Gridview Events
=================================================== SQL Server =================================================== 1)Stored Procdure and Function 2)sql injection 3)improve performance of SP/Query 4)sql profiler performance tuning 5)Table variable(@) 6)Temporary and global Temporary table(#/##) 7)Join(Left,Right,Inner,corss,self,full) 8)union/union all/intersect/minus 9)Triger(after and instedoff with DML) 10)Cursor 11)Index(clusterd,non clusterd for faster retrive data) 12)primary key,unique key,forign key 13)constraint 14)Begin try,begin catch,begin Trans, rollback 15)Distinct,Group by and having,order by 16)view and secure view 17)second Highest salary 18)odd and even row find 19)find duplicate row and delete 20)Factorial number 21)RANK and DENSE_RANK 22)Swapping a column values like ‘1 to 0’ and ‘0 to 1’ of a Table using SQL line query 23)Common Table Expression
=================================================== ASP.Net MVC =================================================== 1)Explain Model,view and controler 2)MVC page life cycle 3)Session mangement(Tempdata(Keep,Peek),viewdata,viewbag)(Tempdata read value in viwe one's it's clear) 4)Bundaling and minification 5)Attribute Routing 6)Routing 7)Scafolding(CURD-Create Update Read Delete) 8)EntityFramwork 9)Areas in MVC 10)Partial view 11)Layout page view 12)viewstart.cshtml 13)viewmodel 14)Validation in mvc(requiredfield,rangevalidatior,campare,custom,validtion summary) 15)exception Handaling(Dataannotation,Handelerror attribute,page.validate) 16)Action Result(12) 15)Action method() 16)anitiforgery token 17)execution sequence of Fileters 18)Antiforgery Token In ASP.NET MVC(for trusted user validation in request) 19)JWT Token based Authentication
================================================== Javascript ================================================== 1)Root element of DOM (root element is the <html> element) 2)Chaining(multiple event can be call on single go) 3)selectors(ID,Element,tag) 4)Cross-site Scripting (XSS) is a client-side code injection attack. 5)=,==,===(['2'==2-true]['2'===2-False]) 6)Arrow functions or fat arrow(=>) same as limda expression for single line scope statement
================================================== Jquery ==================================================1)Jquery selector2)Difference Between $ and $()3)Jquery Ajax call syntax.4)Event Handling in Jquery.If any one have new question ask in recent interview comment here so i can include this in list to help other needy peopleThanks for contribution
Microsoft .NET and SQL Server Developer Blog
Microsoft SQL Server Developer Blog for every one who started the new with Microsoft sql sever
Sunday, 2 August 2020
Dot Net Developer Interview Question
Tuesday, 27 October 2015
Syntax and Example of SQL Server Database and Table Operation Sql Query
Hello reader i have come with the new blog post in this blog i have discribed about the some conman syntax for Sql server using with query like Create database, Alter database, Drop Database, Attach a database, Create a database snapshot, Create table, Alter table, Delete Table, Insert Table, using Select query to insert into table and many more.. i have write this post for inspired to learn from microsoft MSDN and other book.
CREATE DATABASE
Syntax
CREATE DATABASE dbnm
[ CONTAINMENT = { NONE | PARTIAL } ]
[ ON
[ PRIMARY ] <filespec> [ ,...n ]
[ , <filegroup> [ ,...n ] ]
[ LOG ON <filespec> [ ,...n ] ]
]
[ COLLATE collationName ]
[ WITH <option> [,...n ] ]
[;]
<option> ::=
{
FILESTREAM ( <filestreamOption> [,...n ] )
| DEFAULT_FULLTEXT_LANGUAGE = { lcid | languageName | languageAlias }
| DEFAULT_LANGUAGE = { lcid | languageName | languageAlias }
| NESTED_TRIGGERS = { OFF | ON }
| TRANSFORM_NOISE_WORDS = { OFF | ON}
| TWO_DIGIT_YEAR_CUTOFF = <twoDigitYearCutoff>
| DB_CHAINING { OFF | ON }
| TRUSTWORTHY { OFF | ON }
}
<filestreamOption> ::=
{
NON_TRANSACTED_ACCESS = { OFF | READ_ONLY | FULL }
| DIRECTORY_NAME = 'dirName'
}
<filespec> ::=
{
(
NAME = logicalFileName ,
FILENAME = { 'osFileName' | 'filestreamPath' }
[ , SIZE = size [ KB | MB | GB | TB ] ]
[ , MAXSIZE = { maxSize [ KB | MB | GB | TB ] | UNLIMITED } ]
[ , FILEGROWTH = growthIncrement [ KB | MB | GB | TB | % ] ]
)
}
<fileGroup> ::=
{
FILEGROUP filegroup name [ [ CONTAINS FILESTREAM ] [ DEFAULT ] | CONTAINS MEMORY_OPTIMIZED_DATA ]
<filespec> [ ,...n ]
}
ATTACH DATABASE
CREATE DATABASE dbNm
ON <filespec> [ ,...n ]
FOR { { ATTACH [ WITH <attachDatabaseOption> [ , ...n ] ] }
| ATTACH_REBUILD_LOG }
[;]
<attachDatabaseOption> ::=
{
<serviceBrokerOption>
| RESTRICTED_USER
| FILESTREAM ( DIRECTORY_NAME = { 'directoryName' | NULL } )
}
DATABASE SNAPSHOT
CREATE DATABASE databaseSnapshotName
ON
(
NAME = logicalFileName,
FILENAME = 'osFileName'
) [ ,...n ]
AS SNAPSHOT OF sourceDatabaseName
[;]
EXAMPLE
here i give you a example of the create database
USE master;
GO
CREATE DATABASE Emp
ON
( NAME = Emp_dat,
FILENAME='C:\ProgramFiles\MicrosoftSQLServer\MSSQL13.MSSQLSERVER\MSSQL\DATA\mpdat.mdf',
SIZE = 10,
MAXSIZE = 50,
FILEGROWTH = 5 )
LOG ON
( NAME = Emp_log, FILENAME='C:\ProgramFiles\MicrosoftSQLServer\MSSQL13.MSSQLSERVER\MSSQL\DATA\Emplog.ldf',
SIZE = 5MB,
MAXSIZE = 25MB,
FILEGROWTH = 5MB ) ;
GO
ALTER DATABASE
Syntax
ALTER DATABASE { dbnm | CURRENT }
{
MODIFY NAME = newDatabaseName
| COLLATE collationName
| <file_andFilegroupOptions>
| <set_databaseOptions>
}
[;]
<file_andFilegroupOptions >::=
<addOrModifyFiles>::=
<filespec>::=
<addOrModifyFilegroups>::=
<filegroupUpdatabilityOption>::=<setDatabaseOptions>::=
<optionspec>::=
<autoOption> ::=
<changeTrackingOption> ::=
<cursorOption> ::=
<databaseMirroringOption> ::=
<dateCorrelationOptimizationOption> ::=
<dbEncryptionOption> ::=
<dbStateOption> ::=
<dbUpdateOption> ::=
<dbUserAccessOption> ::= <delayedDurabilityOption> ::= <externalAccessOption> ::=
<FILESTREAMOptions> ::=
<HADROptions> ::=
<parameterizationOption> ::=
<queryStoreOptions> ::=
<recoveryOption> ::=
<serviceBrokerOption> ::=
<snapshotOption> ::=
<sqlOption> ::=
<termination> ::=
EXAMPLE
USE master;
GO
ALTER DATABASE Emp
Modify Name = EmpDb;
GO
DROP DATABASE
SYNTAX
DROP DATABASE { databaseName | databaseSnapshotName } [ ,...n ] [;]
EXAMPLE
DROP DATABASE EmpDb;
CREATE TABLE
SYNTAX
CREATE TABLE tableName(
col1 datatype,
col2 datatype,
.....
colN datatype,
PRIMARY KEY( one or more columns )
);
EXAMPLE
CREATE TABLE Emp(
ID INT NOT NULL,
NAME VARCHAR (20) NOT NULL,
ADDRESS VARCHAR (250) ,
PRIMARY KEY (ID)
);
ALTER TABLE
SYNTAX
ALTER TABLE table_name
ADD column_name datatype
EXAMPLE
alter table emp add Age int(5)
SYNTAX
ALTER TABLE table_name
DROP COLUMN column_name
EXAMPLE
alter table emp drop Age
SYNTAX
ALTER TABLE table_name
ALTER COLUMN column_name datatype
EXAMPLE
alter table emp alter Age nvarchar(4)
SYNTAX
INSERT [INTO] tableORview [(columnList)] dataValues
EXAMPLE
INSERT INTO emp(ID, Name)
VALUES (1, 'krunal');
SELECT TABLE WITH OPTIONS
SYNTAX
SELECT *|<field1>,<field2> FROM <Table_NAME>
Example
select * from Emp
OR
SELECT TOP 1000 [ID]
,[Name]
,[Address]
FROM [EMPDB].[dbo].[Emp]
Copy all the columns from one table to existing another table
INSERT INTO Emp2
SELECT * FROM Emp1;
Copy only mention columns we want to insert into existing another table
SYNTAX
INSERT INTO Emp2
(columns))
SELECT columns
FROM Emp1;
EXAMPLE
INSERT INTO Emp2(ID,Name)
SELECT ID,Name FROM Emp1
WHERE Address='Surat';
UPDATE TABLE
SYNTAX
UPDATE tableName
SET column1=value1,column2=value2,...
WHERE column=value;
EXAMPLE
UPDATE Emp
SET Name='Nil', Address='Dubai'
DELETE TABLE
SYNTAX
DELETE FROM tableName
WHERE column=value;
EXAMPLE
DELETE FROM Emp
WHERE Name='Nil' AND Address='Dubai';
WHERE Name='Nil';
i have all the syntax are make using to learn and reference from Microsoft MSDN .
know more about the Sql please visit or refer to MSDN site.
Learn About more please visit Microsoft MSDN Site
so i complete my post now and i come with another post later,any help regarding this post and any query please leave the comment or contact me via email,i try to solve your issue as soon as possible
Thanks
Krunal patel
(Software Developer)
My Popular post click on Link to view
- Introduction of MS SQL Server
- Create a Database in MS Sql Server 2008 R2
- Create a View in MS Sql Server 2008 R2
- Create a New Database User In Sql Server 2008 R2
- Create a New Stored Procedure in Sql Server Step by Step
- Create a Database Backup in Sql Server 2008 R2
- Restore Database in Sql Server 2008 R2
- Sql Server 2008 R2 Connect Via Internet
Monday, 26 October 2015
Auto BackUp Database Maintenance Plans
Hello readers i have come with the new Sql server Blogs for interesting things is "Auto BackUp Database Maintenance Plans" every organization or small farms no time to Backup his database every manually so here is MS Sql Server give you a one Maintenance Plane facility to create a Auto backup plane for as suite for your Comfortable time for back up automatically and store specific location in his hard drive.
click on Ok Button after configuration is finished and then save again the back up plan
Go to the Sqlserver agents one Job is Automatically create with the name of your back up plane.
to confirm the job is working fine to right click on job and the click on "Start job at step" here one porcess window is open and see the progress it's done success check on back up folder backup file created with .bak extension.
in this blog i briefly explain about the how to create and maintain the Sql serve auto backup maintenance plane and configure for you suite.so latest start with the Sql server login.
Login into sql server management studio using the User name and password.
expand the folder Management >> Maintenance Plans
this view like this and then
Right click on Maintenance plans and select New Maintenance Plans
view like this
it's open a new window for give a Maintance plan name so give the perticulat name and then click ok to continue i.e, i give the name "AutoBackup"
next window is open for configure the Autobackup plane configure and create new a sub plan for the autobackup lane currently i am no create sub plan, i only the default plan configure the time and day occurrences, the window look like this view
next i configure the Subplan_1 job schedule for the Database Backup occurs every day on 10:00pm for specific location in my local Storage.
click on ok button after set all the criteria, in this schedule i select the type Recurring for my plan and the go to next .
complete this configuration select the save button to save the Autobackup plan. save plan display in left pan window under "Maintenance plan" window here is right click on Autobackup and select execute to confirm maintenance plan is work fine without error.
Next step is open the Toolbox from view menu and and view the list of component in the toolbox and locate the "Backup Database Task" and select this tool and drag and drop on the subplan_1 area.
Drag and drop the tool on right pan area
Right click on Back Up Database Task and Edit the Plane and configure as you suit.
in this window you can configure the following things for recommended .
- Connection
- Back up Type
- Database
- Back Up Folder to store the back up file
- Back Up file Extension (.bak)
click on Ok Button after configuration is finished and then save again the back up plan
Go to the Sqlserver agents one Job is Automatically create with the name of your back up plane.
to confirm the job is working fine to right click on job and the click on "Start job at step" here one porcess window is open and see the progress it's done success check on back up folder backup file created with .bak extension.
so i complete my post now and i come with another post later,any help regarding this post and any query please leave the comment or contact me via email,i try to solve your issue as soon as possible
Thanks
Krunal patel
(Software Developer)
My Popular post click on Link to view
- Introduction of MS SQL Server
- Create a Database in MS Sql Server 2008 R2
- Create a View in MS Sql Server 2008 R2
- Create a New Database User In Sql Server 2008 R2
- Create a New Stored Procedure in Sql Server Step by Step
- Create a Database Backup in Sql Server 2008 R2
- Restore Database in Sql Server 2008 R2
- Sql Server 2008 R2 Connect Via Internet
Tuesday, 15 September 2015
Create Linked Server in Sql Server 2008 R2
Hi again i came with new post Create Linked Server in Sql Server 2008 R2, Linked server is mainly used to Linked two or multiple server Linked via internet
Linked Server
Step 1:- Open Sql Server Management Studio and login with user name and password
Step 2:- after login success Expand the Instance to view list of the folder and Expand the "Server Objects" folder to display again list of sub folder expand "Linked Server" folder to display the Current Link Server
Step 3:- Right click on the "Linked Servers" Folder and select the first Options "New Linked Server.." look like this
options check the Radio Button "Be Made Using this Security Context" and enter Remote Login and password for Remote computer Sql server connection.
Linked Server
Step 1:- Open Sql Server Management Studio and login with user name and password
Step 2:- after login success Expand the Instance to view list of the folder and Expand the "Server Objects" folder to display again list of sub folder expand "Linked Server" folder to display the Current Link Server
Step 3:- Right click on the "Linked Servers" Folder and select the first Options "New Linked Server.." look like this
Step 4:- Open the New Linked Server Wizard Window, default General options is selected in this options you can configure the Linked Server name and check the Radio Button "Sql Server"
Step 5:- Select a next options is Security on left pan and configure the filed at the bottom of the
Step 6:- at the last select the options "Server Options" and configure the detail in the list of options select one options "RPC Out" to change the 'false' to 'True' and click on OK button to create a new linked server and confirmation message display to linked server create successfully.
Step 7:- New Linked server display in Linked Server folder, now Right click on the New linked server name and select the options "Test Connection" to display one message "The test connection to the linked server succeeded."
so i complete my post now and i come with another post later,any help regarding this post and any query please leave the comment or contact me via email,i try to solve your isssue as soon as possible
Thanks
Krunal patel
(Software Developer)
My Popular post click on Link to view
- Introduction of MS SQL Server
- Create a Database in MS Sql Server 2008 R2
- Create a View in MS Sql Server 2008 R2
- Create a New Database User In Sql Server 2008 R2
- Create a New Stored Procedure in Sql Server Step by Step
- Create a Database Backup in Sql Server 2008 R2
- Restore Database in Sql Server 2008 R2
- Sql Server 2008 R2 Connect Via Internet
SQL Server 2008 R2 Connect Via Internet
Hello Friends I came with my new Sql server post for more interesting topics, here in this post i explain about how to connect Sql server multiple location via internet
Prerequisite
- First of all need a good internet connection (High Speed).
- Ask your internet provider for static IP for you internet connection.
- Sql Server Express 2008 R2 or Any Edition(Minimum Requirement for sql).
SQL Server 2008 R2 Connect Multiple Database Via Internet
Start with Windows Firewall Settings
Step 1:- Run >> Windows Firewall with Advanced Security
Step 2:- Select InBound Rules from Left Pan and Right click on it and select New Rule
Step 3 :- Open an New Inbound Rule Wizard
Step 4:- Select Options on Rule Type "Port" on new wizard window and click on next
Step 5:- Next you can select Options On Protocols and Ports windows "All Local Ports" click next
Step 6:- on Action wizard select options "Allow the Connection" click Next
Step 7:- on Profile wizard check "Domain","Private" and "Public" and click next
Step 8:- at last wizard set the Name of Inbound Rules "Name"(Eg. SQLServer) and "Discription(Optional)" and click Finished button to create Rules on InBound Rules list
Allow Programs Through Windows Firewall
Step 1:- Allow Programs Through Windows Firewall open with new window list of allow program to check Bottom of the window click on button "Allow another Program..." and select following Program
Step 2:- Add following SQL Server Program EXE
- SQL Browser Service ExE
- SQL Server
- SQL Server Management Studio
(Also Start Services for listed program and make sure)
Start Service MSDTC
Step 1:- Go to Run and Type "Services.msc"
Step 2:- Open the Services list window, You can select "Distributed Transaction Coordinates "services
Step 3:- Right click on it and select Properties to open Properties window and select on "General " tab
Step 4:- select Start-up Type "Automatic" and click on Ok Button
Port Forwarding From your Router
Next Step is Port forwarding On you router, Default Sql Server Port is 1433, here i port forward on my Router is 1433
Sql Server Configuration Manager Settings
Step 1:- Open All Program >> Microsoft Sql Serve 2008 R2 >> Configure Tools >> Sql Server Configuration Manager
Step 2:- open Sql Server Configuration Manager Settings window, in this window you can select sql server Network configuration
Step 3:- next you can select your Instance, i.e i secect my instance "Protocol for DEVELOPER2"
Step 4:- Right Click on "Protocols for Developer2" and select Properties
Step 5:- In this window select Tab "IpAddress" and set all the TCP Port options to your Forwarded Port Number, i Set 1433 port click on OK buttton to finished
Step 6:- next Select the options on left pan "Sql server Services " and start "Sql Server Browser " services and "Sql Server(DEVELOPER2)" services Restart
Step 7:- complete all the step the open the "Sql Server Management Studio" and Login with Client Ip Address follow by comma and port number like this
Step 8:- now click on Connect Button You can now connect with Client Sql Server and manage it Multiple sql server on one place
so i complete my post now and i come with another post later,any help regarding this post and any query please leave the comment or contact me via email
Thanks
Krunal patel
(Software Developer)
My Popular post click on Link to view
- Introduction of MS SQL Server
- Create a Database in MS Sql Server 2008 R2
- Create a View in MS Sql Server 2008 R2
- Create a New Database User In Sql Server 2008 R2
- Create a New Stored Procedure in Sql Server Step by Step
- Create a Database Backup in Sql Server 2008 R2
- Restore Database in Sql Server 2008 R2
Wednesday, 12 August 2015
Restore a Database in Sql Server 2008 R2
Hello everyone First of all thanks for visit and my blog and thanks for giving a wonderful comments on my post , here is i come with my another post for How to Restore a Database in Sql Server 2008 R2 Using Back Up file (.bak), so let's start with introduction
How to Restore a Database in Sql Server
First open the sql server Management studio and login with specific user and password, after login go to the left pen and expand the instance, after expand the instance view the list of folder are there expand the database folder and select the database you want to restore and Right click on it.
Right click on database >> Tasks >> Restore >> Database...
Open a new window called "Restore Database" window , here is to tab on left pan is "General" "Options" i explain it here with image, first you can select source you want to get backup database file, here i select the Options "From Device" and click on Browse button Right side on text box to display the select backup file window other is by default is set.
options tab list of option with check box display on right pan, configure all the Restore options and Recovery State as per your requirement, here i configure Restore options is first options is check true the option name is "Overwrite the existing database (With Replace)" and Recovery State is first one is "Leave the database Ready to use by Rolling back uncommitted transactions. additional transaction logs cannot be restored.(RESTORE WITH RECOVERY)" , after complete all the step and then click on "OK" button to start Restore data process....
My Popular post click on Link to view
How to Restore a Database in Sql Server
First open the sql server Management studio and login with specific user and password, after login go to the left pen and expand the instance, after expand the instance view the list of folder are there expand the database folder and select the database you want to restore and Right click on it.
Right click on database >> Tasks >> Restore >> Database...
Open a new window called "Restore Database" window , here is to tab on left pan is "General" "Options" i explain it here with image, first you can select source you want to get backup database file, here i select the Options "From Device" and click on Browse button Right side on text box to display the select backup file window other is by default is set.
Here is open a new window called "Specify Backup", hew you can select the "backup Media to file" because you can backup task is done using backup file and click on "Add" button to add the Backup file with Extension (.bak).
Open new window called "Locate Backup File" to locate your (.bak) file in your system location and select it and click on "OK" Button
Display the Selected file with full location path, make sure the path and file name and the click on "OK" Button to confirm.
Return to main window
Here is display the selected location with file description, Right side of the list is display the Restore check box you can select check to this check box and go to options tab.
options tab list of option with check box display on right pan, configure all the Restore options and Recovery State as per your requirement, here i configure Restore options is first options is check true the option name is "Overwrite the existing database (With Replace)" and Recovery State is first one is "Leave the database Ready to use by Rolling back uncommitted transactions. additional transaction logs cannot be restored.(RESTORE WITH RECOVERY)" , after complete all the step and then click on "OK" button to start Restore data process....
After process completed 100% successfully (Display left bottom corner status is 100%) one message box is display "The Restore of Databasees "DBName" completed successfully" click on "Ok" to close the message and confirm the database table and make sure the changes is restore done.
OR
the second option is to Restore the database using SQL Query
Right click on database >> new query ....
here is the synatax and example of the Restore query
Syntax
RESTORE DATABASE DatabaseName
FROM DISK = 'file path of Backup file is locate' ;
Example
RESTORE DATABASE EMPDB
FROM DISK = 'E:\krunal\data\empdb.bak' ;
after write query successfully execute the query to restore database is
started and complete the process to display the message on Output window
is "Query Completed Successfully"
now i complete the my blog for how to restore the database in
sql server 2008 R2, i wish this is helpful for everyone, you can query
regarding this post plesase comment me or send email..
Thanks
Krunal patel
(Software Developer)
My Popular post click on Link to view
Wednesday, 5 August 2015
Asp.Net Post for Get Home screen tweets from twitter using API and store into SQL Server Database
Get Home screen tweets from twitter using API and store into SQL Server Database
My first Asp.Net article for the twitter tweets related to display latest less than 200 tweet for home screen in ASP.NET page and store in the database table.
Introduction
i search a lots of things related twitter tweets,i found lots of solution on internet using this information and i devlop a one Asp.net application for Display latest tweets on my page and store the tweets in my sql server database and use Visual studio 2010 withe .Net Framework 4.0
Background
First of sign in to twitter using this link https://apps.twitter.com/ and follow the step and Get the
"ConsumerKey"
"ConsumerSecret"
"TokenKey"
"TokenSecretkey"
After get all the twitter key the create a database in MS SQL Server and create a table
code
first Design the Default.aspx page
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id=Head1 runat="server">
<title></title>
<style type="text/css">
#myTitle
{
color: Black ;
font-weight :bolder ;
font-style :normal ;
}
#myDiv
{
background-color: #FFFFFF;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="myDiv" runat="server">
</div>
</form>
</body>
</html>
now next set the key and connection string in Web.config file
<connectionStrings>
<!--put your connection string here-->
<add name="conString" connectionString="Data Source=ServerName/IP;Initial Catalog=dbname;Integrated Security=false;User Id=username;Password=password;Persist Security Info=true; Connect Timeout=1000;Max pool size=25"/>
</connectionStrings>
<appSettings>
<add key="ConsumerKey" value="hMYnAWt4fkZuirxDKvsH2yXe"/> <!--"insert here...";-->
<add key="ConsumerSecret" value="763lji0wK3hrjSgAdC4Jz2XyfIs4nOK4cOo1BHNsBnTvr2vGU"/><!--"insert here...";-->
<add key="TokenKey" value="3171598760-1mfuPn7YpzXRqDnj3Jnm6dg7YkYdN9J8qw7rZ"/><!--"insert here...";-->
<add key="TokenSecret" value="DPjzDM8zy4DUDwtvYSRI4QeCWY9b6AEvP74fySyRc"/><!--"insert here...";-->
<add key="Twitterizer2.EnableStatisticsCollection" value="false"/>
</appSettings>
Now write this code in Default.aspx.cs code file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Security.Cryptography;
using System.Net;
using System.IO;
using Newtonsoft.Json.Linq;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Security.Cryptography;
using System.Net;
using System.IO;
using Newtonsoft.Json.Linq;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
public partial class _Default : System.Web.UI.Page
{
private SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conString"].ConnectionString);
{
private SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conString"].ConnectionString);
//public string query = "mca_krunal";
public string query = "";
// public string url = "https://api.twitter.com/1.1/users/search.json" ;
//public string url = "https://api.twitter.com/1.1/statuses/user_timeline.json"; //Display my tweet
public string url = "https://api.twitter.com/1.1/statuses/home_timeline.json"; //display home tweet with my tweet
public Int16 cnt = 200;
public string query = "";
// public string url = "https://api.twitter.com/1.1/users/search.json" ;
//public string url = "https://api.twitter.com/1.1/statuses/user_timeline.json"; //Display my tweet
public string url = "https://api.twitter.com/1.1/statuses/home_timeline.json"; //display home tweet with my tweet
public Int16 cnt = 200;
protected void Page_Load(object sender, EventArgs e)
{
findUserTwitter(url, query);
}
{
findUserTwitter(url, query);
}
public void findUserTwitter(string resource_url, string q)
{
{
// oauth application keys
var oauth_token = ConfigurationManager.AppSettings["TokenKey"]; //"insert here...";
var oauth_token_secret = ConfigurationManager.AppSettings["TokenSecret"]; //"insert here...";
var oauth_consumer_key = ConfigurationManager.AppSettings["ConsumerKey"];// = "insert here...";
var oauth_consumer_secret = ConfigurationManager.AppSettings["ConsumerSecret"];// = "insert here...";
var oauth_token = ConfigurationManager.AppSettings["TokenKey"]; //"insert here...";
var oauth_token_secret = ConfigurationManager.AppSettings["TokenSecret"]; //"insert here...";
var oauth_consumer_key = ConfigurationManager.AppSettings["ConsumerKey"];// = "insert here...";
var oauth_consumer_secret = ConfigurationManager.AppSettings["ConsumerSecret"];// = "insert here...";
// oauth implementation details
var oauth_version = "1.0";
var oauth_signature_method = "HMAC-SHA1";
var oauth_version = "1.0";
var oauth_signature_method = "HMAC-SHA1";
// unique request details
var oauth_nonce = Convert.ToBase64String(new ASCIIEncoding().GetBytes(DateTime.Now.Ticks.ToString()));
//var oauth_nonce = "8314576e2324d3c9a55bf3f021fd2965";
var timeSpan = DateTime.UtcNow
- new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
var oauth_timestamp = Convert.ToInt64(timeSpan.TotalSeconds).ToString();
//var oauth_timestamp = "1429954519";
var oauth_nonce = Convert.ToBase64String(new ASCIIEncoding().GetBytes(DateTime.Now.Ticks.ToString()));
//var oauth_nonce = "8314576e2324d3c9a55bf3f021fd2965";
var timeSpan = DateTime.UtcNow
- new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
var oauth_timestamp = Convert.ToInt64(timeSpan.TotalSeconds).ToString();
//var oauth_timestamp = "1429954519";
// create oauth signature
var baseFormat = "count={7}&oauth_consumer_key={0}&oauth_nonce={1}&oauth_signature_method={2}" +
"&oauth_timestamp={3}&oauth_token={4}&oauth_version={5}&screen_name={6}";
//var baseFormat = "oauth_consumer_key={0}&oauth_nonce={1}&oauth_signature_method={2}" +
//"&oauth_timestamp={3}&oauth_token={4}&oauth_version={5}&screen_name={6}";
var baseFormat = "count={7}&oauth_consumer_key={0}&oauth_nonce={1}&oauth_signature_method={2}" +
"&oauth_timestamp={3}&oauth_token={4}&oauth_version={5}&screen_name={6}";
//var baseFormat = "oauth_consumer_key={0}&oauth_nonce={1}&oauth_signature_method={2}" +
//"&oauth_timestamp={3}&oauth_token={4}&oauth_version={5}&screen_name={6}";
var baseString = string.Format(baseFormat,
oauth_consumer_key,
oauth_nonce,
oauth_signature_method,
oauth_timestamp,
oauth_token,
oauth_version,
Uri.EscapeDataString(query),
cnt.ToString()
);
oauth_consumer_key,
oauth_nonce,
oauth_signature_method,
oauth_timestamp,
oauth_token,
oauth_version,
Uri.EscapeDataString(query),
cnt.ToString()
);
baseString = string.Concat("GET&", Uri.EscapeDataString(url), "&", Uri.EscapeDataString(baseString));
var compositeKey = string.Concat(Uri.EscapeDataString(oauth_consumer_secret),
"&", Uri.EscapeDataString(oauth_token_secret));
"&", Uri.EscapeDataString(oauth_token_secret));
string oauth_signature;
using (HMACSHA1 hasher = new HMACSHA1(ASCIIEncoding.ASCII.GetBytes(compositeKey)))
{
oauth_signature = Convert.ToBase64String(
hasher.ComputeHash(ASCIIEncoding.ASCII.GetBytes(baseString)));
}
using (HMACSHA1 hasher = new HMACSHA1(ASCIIEncoding.ASCII.GetBytes(compositeKey)))
{
oauth_signature = Convert.ToBase64String(
hasher.ComputeHash(ASCIIEncoding.ASCII.GetBytes(baseString)));
}
// create the request header
var headerFormat = "OAuth oauth_nonce=\"{0}\", oauth_signature_method=\"{1}\", " +
"oauth_timestamp=\"{2}\", oauth_consumer_key=\"{3}\", " +
"oauth_token=\"{4}\", oauth_signature=\"{5}\", " +
"oauth_version=\"{6}\"";
var headerFormat = "OAuth oauth_nonce=\"{0}\", oauth_signature_method=\"{1}\", " +
"oauth_timestamp=\"{2}\", oauth_consumer_key=\"{3}\", " +
"oauth_token=\"{4}\", oauth_signature=\"{5}\", " +
"oauth_version=\"{6}\"";
var authHeader = string.Format(headerFormat,
Uri.EscapeDataString(oauth_nonce),
Uri.EscapeDataString(oauth_signature_method),
Uri.EscapeDataString(oauth_timestamp),
Uri.EscapeDataString(oauth_consumer_key),
Uri.EscapeDataString(oauth_token),
Uri.EscapeDataString(oauth_signature),
Uri.EscapeDataString(oauth_version)
);
Uri.EscapeDataString(oauth_nonce),
Uri.EscapeDataString(oauth_signature_method),
Uri.EscapeDataString(oauth_timestamp),
Uri.EscapeDataString(oauth_consumer_key),
Uri.EscapeDataString(oauth_token),
Uri.EscapeDataString(oauth_signature),
Uri.EscapeDataString(oauth_version)
);
ServicePointManager.Expect100Continue = false;
// make the request
var postBody = "screen_name=" + Uri.EscapeDataString(query) + "&count=" + cnt.ToString();//
//var postBody = "screen_name=" + Uri.EscapeDataString(query) ;//
url += "?" + postBody;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Headers.Add("Authorization", authHeader);
request.Method = "GET";
request.ContentType = "application/x-www-form-urlencoded";
var response = (HttpWebResponse)request.GetResponse();
var reader = new StreamReader(response.GetResponseStream());
var objText = reader.ReadToEnd();
myDiv.InnerHtml = objText;/**/
var postBody = "screen_name=" + Uri.EscapeDataString(query) + "&count=" + cnt.ToString();//
//var postBody = "screen_name=" + Uri.EscapeDataString(query) ;//
url += "?" + postBody;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Headers.Add("Authorization", authHeader);
request.Method = "GET";
request.ContentType = "application/x-www-form-urlencoded";
var response = (HttpWebResponse)request.GetResponse();
var reader = new StreamReader(response.GetResponseStream());
var objText = reader.ReadToEnd();
myDiv.InnerHtml = objText;/**/
string html = "";
try
{
JArray jsonDat = JArray.Parse(objText);
try
{
JArray jsonDat = JArray.Parse(objText);
html = html + "<b id='myTitle'>Total Tweet Cout :</b>" + jsonDat.Count().ToString() + "<br/><br/><hr>";
for (int x = 0; x < jsonDat.Count(); x++)
{
html = html + "<b id='myTitle'>ID :</b><br/>" + jsonDat[x]["id"].ToString() + "<br/>";
html = html + "<b id='myTitle'>Tweet :</b><br/>" + jsonDat[x]["text"].ToString() + "<br/>";
html = html + "<b id='myTitle'>Created On :</b><br/>" + jsonDat[x]["created_at"].ToString() + "<br/><br/><hr>";
for (int x = 0; x < jsonDat.Count(); x++)
{
html = html + "<b id='myTitle'>ID :</b><br/>" + jsonDat[x]["id"].ToString() + "<br/>";
html = html + "<b id='myTitle'>Tweet :</b><br/>" + jsonDat[x]["text"].ToString() + "<br/>";
html = html + "<b id='myTitle'>Created On :</b><br/>" + jsonDat[x]["created_at"].ToString() + "<br/><br/><hr>";
InsertTweetIntoDB(jsonDat[x]["id"].ToString(), jsonDat[x]["text"].ToString(), jsonDat[x]["created_at"].ToString());
}
myDiv.InnerHtml = html;
}
catch (Exception twit_error)
{
myDiv.InnerHtml = html + twit_error.ToString();
}
}
myDiv.InnerHtml = html;
}
catch (Exception twit_error)
{
myDiv.InnerHtml = html + twit_error.ToString();
}
}
//Firest create table into in your db name"Table_Tweet"
public void InsertTweetIntoDB(string ID, string TweetTXT, String Created_AT)
{
con.Open();
//Query to insert images path and name into database
SqlCommand cmd = new SqlCommand("Insert into Table_Tweet(ID, TweetTXT, Created_AT) values(@ID, @TweetTXT, @Created_AT)", con);
//Passing parameters to query
cmd.Parameters.AddWithValue("@ID", ID);
cmd.Parameters.AddWithValue("@TweetTXT", TweetTXT);
cmd.Parameters.AddWithValue("@Created_AT", Created_AT);
cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
//Close dbconnection
con.Close();
}
SqlCommand cmd = new SqlCommand("Insert into Table_Tweet(ID, TweetTXT, Created_AT) values(@ID, @TweetTXT, @Created_AT)", con);
//Passing parameters to query
cmd.Parameters.AddWithValue("@ID", ID);
cmd.Parameters.AddWithValue("@TweetTXT", TweetTXT);
cmd.Parameters.AddWithValue("@Created_AT", Created_AT);
cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
//Close dbconnection
con.Close();
}
public void UpdateTweetIntoDB(string ID, string TweetTXT, String Created_AT)
{
con.Open();
SqlCommand cmd = new SqlCommand("update Table_Tweet set ID=" + ID + ", TweetTXT='" + TweetTXT + "', Created_AT='" + Created_AT , con);
cmd.ExecuteNonQuery();
con.Close();
}
{
con.Open();
SqlCommand cmd = new SqlCommand("update Table_Tweet set ID=" + ID + ", TweetTXT='" + TweetTXT + "', Created_AT='" + Created_AT , con);
cmd.ExecuteNonQuery();
con.Close();
}
}
Interest
i have learn lots of new things from this demo and thank all the guys who help me for this assignment,i hope this is helpful for needy people...
Thanks
My Popular post click on Link to view
- Introduction of MS SQL Server
- Create a Database in MS Sql Server 2008 R2
- Create a View in MS Sql Server 2008 R2
- Create a New Database User In Sql Server 2008 R2
- Create a New Stored Procedure in Sql Server Step by Step
- Create a Database Backup in Sql Server 2008 R2
Subscribe to:
Posts (Atom)