Tuesday, September 14, 2010

Asp.net website in hindi or other native language with simple steps

Dear all,
For Indian its great news that you can now create web site in your native language like Hindi, Marathi, Punjabi, Urdu, Tamil etc.
Kudos to Microsoft for introducing “Microsoft Indic Language” with help of this we can easily create web site in any language without doing much efforts.
So here we go with the sample and things to remember with simple step



Step 1:- Add following line in your html page
< input type=”hidden” id=”MicrosoftILITWebEmbedInfo” attachMode=”optout” value=”" />



Remember here: I am using hindi here that’s why i used hindi.js you can use your own choice.
Step 2:- Add new attribute with each input control which is “MicrosoftILITWebAttach” as shown in below.
< asp:TextBox ID=”txtPost” runat=”server” MicrosoftILITWebAttach=”true” >

Step 3:- If you want to store this value in database the just remember all the field which contain string data type should be “NVARCHAR”
Otherwise your searching will not work and all the data will be change to question mark instead of actual data.

Step 4:- for searching in database hindi text or text which you insert you have to use following syntax

SELECT * FROM tblPost where postName =N’प्रोफेसर’
So Enjoy

Thanks
Rajat
Toy Story 3 (Four-Disc Blu-ray/DVD Combo + Digital Copy)

How to resolve Log Shipping Error “Exclusive access could not be obtained because the database is in use.RESTORE LOG is terminating abnormally”?

Hello Friends,
This error normally came when you did log shipping on your database and your secondary server database in stand by mode.
In this error your secondary server database restore job will not work. To resolve this error you just need to change the log shipping setting.
When you configure secondary server database mode there is check box which says disconnect all collection at the time of restore database so just check that check box and you will find your log shipping is working.
Thanks

Rajat

Leave a Comment
How to shrink Log File when Log shipping is implemented on database ?
Filed under: Sql server — indiandotnet @ 7:29 pm
Tags: Log Shipping, Rajat, Sql server

To shrink Log file you have to run following command.
DBCC SHRINKFILE ( ‘Database_log’ , NOTRUNCATE)
So here we used NOTRUNCATE option because in log shipping transaction log sequence important if you run the normal Shrink file or with truncate file option then log shipping will be failed.
So run Shrink File with NOTRUNCATE option. Although many DBA & Sql Server experts gave suggestion to avoid shrink Log file.
But we can do shrink file in log shipping with NOTRUNCATE option if database Log size too much large and you have space issue.
Thanks

Rajat
Toy Story 3 (Four-Disc Blu-ray/DVD Combo + Digital Copy)

Learn Simple SQL Server Integration Service example database to text file transformation in 5 minutes

Dear Friends,
Today we are going to create simple SSIS task which we will create a text file output using ETL (Extract Transform Loading) of SSIS.
For this first basic this which we need to know
1) Source Database
2) Output file name & path

Step 1:- Open SQL Server Business Intelligence Development Studio (BIDS) and create a new Integration project as shown in below fig.


Step 2:- Now drag and drop Data Flow Task from control flow item’s toolbar as shown in below fig.



Step3:- Once you done with this just double click on Data flow task and you will get a new screen for data flow. Now we have to choose data source for our ETL process for this just drag drop data source from data flow source tool bar.
Step 4:- configure source database. In this example we are using OLEDB data source and SQL server Database. You can choose other database source too. To configure OLEDB data source just right click the OLEDB data source and click on Edit.


You will get OLEDB Source Editor as shown in fig.
Just click on new button as highlighted in above fig set database. Once database source is done we can choose any data mode like table or view, SQL Command as shown in fig.


I am choosing table employees of North wind database here. After doing this just choose desire column which you want to export in file. You can choose this column by selecting columns option.




Step 5:- Now Drag drop destination control as we require flat file destination and configure it. We can configure destination same as we did for data source. Just right click on flat file destination control and edit it.


Step6: – Once you done with configuration of file click on mapping and map the columns. As shown in below fig.



Step 7:- Now all set just run using”F5”



If everything is green then our SSIS package is done successfully.
In next session we will learn how to deploy it, how to use configuration for it.
Till than enjoy SSIS.

Thanks
Rajat Jaiswal
Triple Exposure

Replication – A way of disaster management

What is Replication?

Replication is another way of disaster recovery with the help of this we can recover our database and we do not need to do much manual efforts.

Replication is the way by which you can transfer data or database object from one server to another server, synchronize them, and maintain them identical.

The interesting part is you can implement replication for any location like LAN, WAN, Internet without much effort.

What is the initial requirement for Replication?

The replication can work on SQL server 2000 2005, 2008.

What are the good points of Replication?

There are many advantage of replication

•High availability solution
◦Minimum error
◦Easy to implement
What are the points which we would not like for replication?

•Main server overhead increase
•If there is failover occurs then we have to handle that manually
What are the terminologies we used in Replication?

We used following terminologies in replication

1) Publisher:-

The publisher is main database source which publish data or other data object to different server or we can say subscriber.

2) Subscriber :-

The Subscriber by name it is clear that it subscribe the database from publisher server.

3) Distributor :-

The distribution is the server which manages flow of the data. It not mandatory to have distributor always. A publisher sever can manage role of both (publisher & distributor).

4) Article:-

An article can be any data object like data table, Rows, Store procedure or view. A publisher can be published number of article.

What are the different types of Replication?

We can implement 3 type of replication

Snapshot Replication, Transactional Replication, Merge Replication.

Snapshot Replication:-

By the name it is clear that in this publisher take snap shot of entire database and publish to the subscriber. And when its take full snap shot obviously it taking it consumes more resource. Or we can say its resource intensive process. It also known as simple replication. It used where database changes are rarely.

Transactional Replication: It also known as dynamic replication.

In this the publisher and subscriber are always synchronized. It used where we need exact same copy on subscriber with immediate effect. It can be useful when subset of database or table is required.

Merge Replication:-

It’s very interesting replication by the name it’s clear that it use merge method. In this both publisher and subscriber has freedom to work without network and when they connect the replication agents check both the database and merge each other’s changes. In merging if any conflict occurs than preference is given to publisher.

Later on in the post we will get a brief introduction how to implement replication tillthan enjoy definition .

Thanks & Regards

Rajat
Triple Exposure

Log Shipping – A way for disaster management

Hello friends,

Today we will see how log shipping is helpful to us. so just checkout basic first then we will implement it.

What is Log Shipping?

Log Shipping is another one of most fascinating feature provided by SQL Server for disaster management. With the help of this technique we can update keep distributed copy of our database on another server. It can backup transaction log, restore them, distribute them to different location. To achieve this automated process SQL server used SQL server job agents.

Or we can say Log shipping has following functionality

•It backups transaction log of main server
•It transfers transaction log to predefine distributed location
•It restore transaction log to secondary server


What is the initial requirement for achieving the Log shipping?

Log shipping is handle with SQL server 2005 version onwards no other extra software or hardware require to achieve this.

What are the different terminologies used for Log Shipping?

For Log shipping we have used following terminologies

•Primary server:-
Primary server is main server from where we have to copy the database transaction log it contain main database or primary database server.

•Secondary Server :-
Secondary server is another server or we can say its stand by server on which transaction log is restored to maintain database availability. The secondary database can have same database objects & data after Log shipping.

•Monitor server :-
Monitor server by name it’s clear that it maintain or monitoring the activity of log shipping.

What are the benefits of Log Shipping?

•Easy to implement no extra efforts required to maintain it
•No extra software or hardware required
•Fast then other previous backup process
•Multiple secondary server is available
What the unlike things with Log Shipping?

The things which we can say not like for our use is

•No automated failover recovery we have to manually shift the server setting to activate secondary server when primary server is down
•It not reflects immediate effect on secondary server.
•Log shipping cannot be scripted it means you cannot mimic production server logs hipping to testing server.
•Possible Database Loss if primary server fails.
•Difficult troubleshooting
In next few post i will show how to implement Log shipping.

Till than enjoy the SQL Server.

Thanks

Rajat
The Adventures of Sherlock Holmes

How to determine whether particular port is open or not with IPAddress?

Dear All,

Sometime you face problem that whether a particular port is open or not for an IPaddress. The reason may be firewall so first disable firewall.

So to determine this do particular steps.

Step 1:-

Click on start button of windows.

Step 2:-

Click on Run

Step 3:-

Type cmd and press enter

Step 4:- you will get command prompt screen type Telnet in command prompt screen

You will get Telnet Prompt.

Step 5: type OPEN IPAddress port



Step 6:- press enter if new blank window is Opened then port is open for IPAddress otherwise it not.

Hope this will help you.

Thanks

Rajat
The Adventures of Sherlock Holmes

step-by-step-sql-server-mirroring-a-way-of-disaster-recovery-part-IInd

Hello Friends,

I hope you have lovely weekend.

Today I am going to continue our second part of mirroring which is part II. In this part we are going to implement mirroring step by step. just few steps and mirroring will work for us.

Step 1:- Just right click on primary server’s database on which we have to setup mirroring.

Once you right click you get following option just click on Mirroring option as shown in figure.

Just click on “Configure Security option”




Step 2:- Once you click the mirroring option you will get following option screen.



If you want witness server then check witness server yes option otherwise continue with no option

I don’t require that so I selected “no” option.

Step 3:-

Once you click next then you will get following screen related primary server.

You just need to click next.



Step 4:- In the next step you will ask for mirror server so just connect with the mirror server.

**** The point which needs to remember that on mirror server database the database should be restored with “No recovery option” with same name.



Step 5:- You will get Service account screen as shown below once you clear the step 4.

Now here if you have any special credential for services then give that credential otherwise leave it blank in my case I keep it blank.



Step 6:- Once you pass with screen 5 you get following screen. If everything successful then you will get success status as shown in below fig.



Step 7:- when you click finish then you will get mirroring option as shown in fig.

Just click on start mirroring option then mirroring start if everything is right.



I am 80% sure that mirroring will work with this step but 20% not just because sometimes few errors comes like authentication, Server URL & Port etc so In coming chapters I will explain the errors which will you face in implementing mirroring.

Till than enjoy mirroring.

Thanks

Rajat Jaiswal
Toy Story 3 (Four-Disc Blu-ray/DVD Combo + Digital Copy)

Step by Step SQL Server Mirroring a way of Disaster Recovery Part -1

After reading few articles and self analysis I think SQL server mirroring can be understand by my style. So I note down all the queries which are in my mind and try to find out answer for them. Other than that
I have implemented step by step creation of mirroring. Hope it will work for other programmers, DBA also for understanding.
What is SQL Server Mirroring?
SQL Server Mirroring is latest feature supported in SQL Server 2005 for disaster management. It assures data availability if principal server fails. In the mirroring database transaction log transfer from one server to another server automatically. And within few minutes other stand by server is ready if main server get down or some fault occurred.
What is initial requirement for SQL Server Mirroring?
For SQL server mirroring we should have SQL SERVER 2005 with Sp1 onward.
What are the advantages of SQL Server Mirroring?

• It provides high availability of database.
• Comparatively easy to implement.
• No Extra hardware required to implement.
What are the drawbacks of SQL Server Mirroring?
Its individual choice whether they take it as a drawback or extra feature or requirement. According to me below is main point which I don’t like.
• It slowdown your main database server.
• In some case we cannot use mirror database directly because it treated as read only database or we can say Snapshot.

What are the main terminologies used with SQL Server Mirroring?
Below are main terminologies which I think used in mirroring:-
Principal Server: – The principal server is the server which is mainly responsible to give response to end user. The end user is connected with this server first. The Primary database exists on this server.
Mirror Server: - The mirror server contains the copy of main database. The copy of main database is called mirror database and the server is called mirror server. In other words we can its stand by server which is updated by principal server by providing transaction log. Ideally it is not connected with end user.
Witness server: - The Witness server is an optional server. Witness server different from Principal server & Mirror server. It provides mechanism for automatic failover. In other words we can say that when primary server fail then end user connected to witness server instead of mirror which help out end user for database failover situation.
End points: – By the name it clear that it contain address and port number for connection between principal
Quorum – Quorum is the minimum relationship among the entire connected server.

What are the different modes of mirroring?
Basically mirroring work with 2 modes which are synchronous & Asynchronous.
1) Synchronous Mode: – This is high safety mode. In this every transaction which is committed on principal server will also need to be committed on mirror server on same time. It acknowledges end user only when transaction is committed on both servers. It can be achieve with 2 options
a) High safety with automatic failure-
By then name it is clear that if something going wrong means failure happened then we have to manually take care of end user connectivity.
b) High safety without automatic failure:-
With help of this feature we don’t have to do much effort at the time of failure automatically end user pointed to another server.

2) Asynchronous Mode: – This is high availability mode. In this principle server send transaction log but he don’t wait for acknowledge response. Means principle server committed transaction without waiting for response of mirror database. It does not provide automatic failover to the end user.

In Next part we will take a look for step by step implementation.

Thanks & Enjoy Mirroring

Rajat
Kindle Wireless Reading Device, Wi-Fi, 6" Display, Graphite - Latest Generation

How to determine Which Index will be helpful in SQL server Database table?

Hello Friends,
Today I have to do some performance tuning work for a store procedure on a database which has millions on records.
So I just tried basic first with like dbo uses, proper joins, avoiding of inline queries. But could not get a huge success.
Then I tried for index. But the thing which is in mind that which index should be appropriate for my table which has millions of records.
I am in dilemma which index should be appropriate I just wondering the utility which give some sort of guidance because as we know Indexing is very critical thing in both the way if we increase the index insert & delete, update will be slow.
And size of database is also increase so it should be very effective.
So in searching I find a useful thing which Dynamic View Management (DVM) Which is helpful in finding proper index.
I find “sys.dm_db_missing_index_details”
Which provide you information of missing index. It give basically return following columns when you run it.
Index_handle, database_Id, object_Id, Equality Columns, Inequality Columns, included columns and statements.



Now we have to mainly concentrate on Equality columns, Inequality Columns, and included columns these 3 columns has their own indication
1)Equality columns:-
It mainly have the actual database table column name(s) on which we can create new index. Most of the time this column is where clause , join etc. as shown in fig
2)Inequality Columns:-
This are the columns which we have to avoid for index most of the time this column is null but if have value then we have to check it out and exclude from index.(As shown in fig)
3)Included columns:- This column can be included in creating new index if required (as shown in fig)

So from above fig if I need to figure out some conclusion than I can say I will create a index on tblSample table on the basis of equality columns which is productBatchId and more over I can include other columns like serializationId, client id also if required.

So in this way DVM command help in guiding Index.

I hope you will also take advantage of this.

Enjoy SQL
Enjoy Indexing.

Thanks
Rajat
Kindle Wireless Reading Device, Wi-Fi, 6" Display, Graphite - Latest GenerationKindle Wireless Reading Device, Wi-Fi, 6" Display, Graphite - Latest Generation

How to determine Size & rows in database tables ?

Dear All,
Today I got task to determine the table size which table taking how much space on disk.
So I have write the following script to determine that I hope It will help you out somewhere.
Just checkout
BEGIN TRY
DECLARE @tblName AS VARCHAR(200)
DECLARE @tblTest TABLE ([Name] VARCHAR(100),
[rows ] INT,
reserved VARCHAR(100),
data VARCHAR(100),
index_Size VARCHAR(100),
Unused VARCHAR(100))
DECLARE cur_Test Cursor FOR SELECT [name] FROM sys.objects WHERE [type] = ‘U’
OPEN cur_Test
FETCH NEXT FROM cur_test INTO @tblName
WHILE @@FETCH_STATUS = 0
BEGIN
INSERT INTO @tblTest
EXECUTE sp_spaceUsed @tblName
FETCH NEXT FROM cur_test INTO @tblName
END
CLOSE cur_Test
DEALLOCATE cur_Test
SELECT * FROM @tblTest ORDER BY rows desc
END TRY
BEGIN CATCH
SELECT ERROR_LINE(),ERROR_NUMBER(),ERROR_MESSAGE()
END CATCH

Enjoy Programming
Thanks
Rajat Jaiswal
The Suburbs

Simple web Browser with Animation using WPF

Dear Friends,
How are you ?
Today we will create a simplest web browser in WPF with some basic animation handling.
To do this task we have a simple control which is webBrowser control.
We need to just drag & drop webBrowser control and design the screen as you need just check out below fig.

once you done with the design.
Then to open a web page in browser control you need navigate method provided by webbrowser control.
The navigate method has string, uri parameter so you can utilize that according to your need.
Just check out below code.

The browser control also maintain forward , back history which we can utilize according to our need. Please see below code for that.

We can very much customize the web browser like block particular URL , bookmark etc.
Now you are just wondering that what is animation here ? so I would like to say that WPF give us tremendous opportunity for eye catching look and animation.
It give approx. 32 different animation object which is helpful in different scenario. All are available with name space “System.Windows.Media.Animation
”. Here I am with One of the simplest object which is double Animation.
The double animation is just basic animation control which can be utilize for animation you can do it with either XAML or code.
Here I am giving example of code.
So check out below code.
Dim da As New DoubleAnimation()
da.From = 30
da.To = 300
da.Duration = New Duration(TimeSpan.FromSeconds(1))
Me.wbctrl.BeginAnimation(WebBrowser.HeightProperty, da)
da.AutoReverse = True
da.RepeatBehavior = RepeatBehavior.Forever

Here wbctrl is webBrowser control . The double animation has duration property for how much time it will take. It has auto reverse property to
In the above code we using height property animation . just see below line
Me.wbctrl.BeginAnimation(WebBrowser.HeightProperty,da)

In similar manner you can go for width , position , opacity etc.
For more detail information please download attached code at

Enjoy coding.
Thanks
Rajat jaiswal
The Suburbs

How to make a website SEO Compatible ?

Hello Friends,
It’s quite obvious that if you make a website than you all need that it should come up in search engine like Google, yahoo, msn etc and many more easily.
For that there are first and most important thing is that your site should be compatible with SEO.
So you think what is SEO? How is it implement with my site ?
So here we goes to understand SEO.
Basically SEO is Search Engine Optimization. When your site is SEO Compatible it means your site easily search in search engines.

I am providing some basic steps how to make your site compatible with SEO.

1) URL Name:-
First and most important thing is your domain name. It should relevant to your content like if you are site has relevant to blog, then there should be blog related word, if its related to Job then there should be job related word, if its related to social cause then there should be social cause relevant word in your domain.

“If you have already booked domain name” then need not to worry we have some other few steps.

2) Title :-
Another most important thing is title. Google and other search engine scan title first so that should be very relevant.

3) Meta :-
Meta Description is another important so there should be relevant description which help in searching for end user to search in search engine.

4) Image name:-
Image name should be relevant to the site the keyword. Image name should be related to keyword.
For example if image name is image1.jpg than it should be Free-music.jpg. I mainly prefer it should started with your domain, or keywords.
You should use Alt attributes .

5) H1 (Headline) tag use :-
Headline tag like H1 to H6 very important. They play important role in search. So whatever which is relevant to your web site that can be used in search should be in H1 to H6 tag.

6) Hyper Reference :-
Whenever you are providing the hyper reference then that should be relevant to keyword which can we search.

7) Other than that you can add your page or website in Google, Yahoo, MSN and other search engine.

8) Create Page name relevant to keyword

9) Create back links for your websites, Do blogging , twitting for website.

10) Last but not the least pay Google or other search engine for showing your website in sponsor links.

I hope it will help you.

Thanks
Rajat Jaiswal
Samsung Captivate Android Phone (AT&T)

VS-2010 environment

Hello Friends,
It’s great to hear that Microsoft finalized VS-2010 and we can get release mode now.
As you know VS-2010 is based on WPF so lots of changes related to visualization you will a new attractive IDE.
Just see blow image

There is some new project list also as shown in below fig
In this you can find mainly MVC2 application project, Cloud project & more over Share point.

You can find lot of new feature with VS 2010.
Like inherited View State, Routing for SEO related options, parallel LINQ,
For more information you can checkout link http://www.asp.net/learn/whitepapers/aspnet4/default.aspx

Thanks
Rajat
The Adventures of Sherlock Holmes

Simple Game With WPF

Hello Friends,
As we know WPF is mainly related with designing stuff. So I just tried to utilize basic designing stuff and try to make a simple game which is Tic-Tac-To.
Right now the game use simple but attractive graphics (as you know I am not a good designer).
Later on we will make it more attractive using images.
You can download source code from Download Link

Till than b bye.
Enjoy Tic-Tac-To game.
Thanks
Rajat


Hello Friends,
As we know WPF is mainly related with designing stuff. So I just tried to utilize basic designing stuff and try to make a simple game which is Tic-Tac-To.
Right now the game use simple but attractive graphics (as you know I am not a good designer).
Later on we will make it more attractive using images.
You can download source code from Download Link

Till than b bye.
Enjoy Tic-Tac-To game.
Thanks
Rajat
Toy Story 3 (Four-Disc Blu-ray/DVD Combo + Digital Copy)

Play Music with WPF

Hello friends,
Today I am coming with another passion after computer. “Music” is part of my life if it’s not in my life than I don’t know what happened to me. So I am dedicating this small creation to my musical friends who helps, enjoy music. Here I am with solution how to play synthesizer by WPF application.
I choose WPF here just because it’s very much attractive and I seem its give emphatic vision to my program, so friends its very simple and attractive task. We have to go in 3 simple steps.
Step1:- Design a WPF page with buttons as shown below fig.

Step2:- Download notes wav file (Sa,Re,Ga,Ma, Pa’s wav file) and include in your project.
Step3:- Now play music on key press and button click event as shown below
Dim btn As Button = CType(sender, Button)
Dim player As New SoundPlayer

Dim strPath As String = Configuration.ConfigurationManager.AppSettings(“path”).ToString()
Select Case btn.Name
Case “btnA”
player.SoundLocation = strPath & “\a.wav”
Case “btnB”
player.SoundLocation = strPath & “\b.wav”
Case “btnC”
player.SoundLocation = strPath & “\c.wav”
Case “btnD”
player.SoundLocation = strPath & “\d.wav”
Case “btnE”
player.SoundLocation = strPath & “\e.wav”
Case “btnF”
player.SoundLocation = strPath & “\f.wav”
Case “btnG”
player.SoundLocation = strPath & “\g.wav”
Case “btnH”
player.SoundLocation = strPath & “\gg.wav”
End Select
player.Play()
player.Dispose()
You can download the source code from Download link

I hope you all are musical lover and use it enhance it and more over send me updated version 
Enjoy music with dot net.
Thanks
Rajat Jaiswal
Kindle Wireless Reading Device, Wi-Fi, 6" Display, Graphite - Latest Generation

integrate twitter with asp.net in 3 easy steps.

Hello friends,
Here I am with new and very interesting topic which is how to integrate twitter with your application and more over the application is in WPF (windows application).

To integrate Twitter we have Twitterizer.Framework.dll
Which you can download from http://code.google.com/p/twitterizer/

Once you download that just copy Twitterizer.Framework.dll and past in your project’s bin folder.
After this set reference of twitterizer.FrameWork.dll in your project.
Once you done with this now everything will go smooth now.
To connect with Twitter you have to write following code.
Private pvt_Twt As Twitter
pvt_Twt = New Twitter(Me.txtName.Text, Me.txtPassword.Password)
Once you done with this and if any error does not come means you won half battle.
Now you have to play with above object.
Suppose you want to set new status on your twitter then. You have to write following code.
Me.pvt_Twt.Status.Update(Me.txtStatus.Text)


Now suppose you want to know information about your friends and no. of follower to them
Then you have to write following code.
Dim twfriends As TwitterUserCollection = Me.pvt_Twt.User.Friends()
Dim str As New System.Text.StringBuilder
For Each TwitterUser As Twitterizer.Framework.TwitterUser In twfriends
str.Append(“ScreenName : ” & TwitterUser.ScreenName.ToString() & vbCrLf)
str.Append(“No of Followers: ” & TwitterUser.NumberOfFollowers.ToString() & vbCrLf)
str.Append(“———————————————————–” + vbCrLf)
Next
Me.txtQuery.Text = str.ToString()



Now suppose if you want to see all status then you have to write following code
Dim twStatusCollection As New Twitterizer.Framework.TwitterStatusCollection
twStatusCollection = Me.pvt_Twt.Status.UserTimeline()
Dim str As New System.Text.StringBuilder
For Each tws As TwitterStatus In twStatusCollection
str.Append(“status: ” & tws.Text & “Created” & tws.Created.ToString() & vbCrLf)
str.Append(“User :” & tws.TwitterUser.ScreenName.ToString() + vbCrLf)
str.Append(“—————————————————–” + vbCrLf)
Next
Me.txtQuery.Text = str.ToString()

This just a sample which I tired more over you can sent direct message to user.
Delete any status. Delete and friend, with this DLL.
For learning purpose I used it and enjoyed a lot .I hope you like it and dig more to enjoy facility of twitterizer.framework.dll.
More over you can download the code from
Download link

Thanks
Rajat
The Suburbs

How to find Mobile Location and provider ?

Dear all,
Today we are going to do some interesting things which are find mobile location with dot net.
Many time we got wrong number but we don’t know from where it comes with the help of this utility you are near about that location and service provider.
If you are not aware of mobile number system then it is too exciting for you just like me before I started this project.
Actually this utility not giving exact location but it gives the state and capital combination means near about that location you can find the mobile.
To understand the project we started with Mobile Number system.
The starting 4 number in any mobile number in India is pre decided by TRIA (Telecom Regulatory Authority of India).
This starting 4 number is called MSC code (Mobile Switching center).
This 4 number decide which provide giving his service to which area of India.
Here provider means IDEA, BSNL, AIRTEL etc.
As I got this information what I did I collect all the provider information first.
Secondly I find all area detail of India. And last but not the least prefixes 4 digit of mobile number in different area with providers.
Once I got this I made a database with this three combination
1) lkuArea table:- in this I keep area code, state Name, state Capital
2) lkuServiceProvider table – in this I keep provider code, provider name, provider web site
3) tblMobileCode table – in this we keep MSC code, lngAreaId, lngService Provider id.

Once I did this. Then I inserted the data according to the need of application. I have created utility to import Excel to our Mobile Track database.

Then I thought instead of showing the simple location why not we use Google map.
So I used Google map to point out position.

In this way we created this task.

You can checkout the code at http://www.mymobilelocation.tk/

More over in next couple of week I will show you how to track your mobile’s real time position.
It’s also very interesting thing.
Please give you your feedback on this.

Thanks
Rajat Jaiswal
Triple Exposure

Monday, September 13, 2010

File Download in asp.net in 5 minutes

Hello friends,

It’s almost 2 week that I did not post any article friends sorry for that busy in some other high priority task. Today we will work on how to download a file with asp.net which exists in database.

So friends here we go.

Let us suppose we have a table of document in which we keep document in binary format. Suppose the table structure is as follows.
lngId
strFileName
strDescription
strContentType
binDocumentFile

Now what we have to do is by passing just lngId we will download the file or open in browser.
The code for doing this so simple.
Which I mention below

Dim sqlcon as New Sqlconnection(strConnectionString)
Sqlcon.open()
Dim ds as new dataset
Dim sqlcmd as new sqlcommand
Sqlcmd.connection =sqlcon
Sqlcmd.commandType = commandtype.storeprocedure
Sqlcmd.commandtext = “proc_getDocumentById”
Sqlcmd.parameters.add(“@lngId”,intDocumentId) ‘int documented is lngID of document
Dim sda as new sqldataAdapter
Sda.selectCommand = sqlcmd
Sda.fill(ds)

If ds Is Nothing = False AndAlso ds.tables(0).rows.count >0 Then
Dim dr As dataRow = ds.tables(0).Rows(0)
Context.Response.Clear()
Context.Response.ContentType = dr (“DOCTYPE”).ToString()
Dim intLength As Integer = DirectCast(dr (“DOCDATA”), Byte()).Length()
Context.Response.AddHeader(“Content-Disposition”, “inline;filename=” & dr (“DOCNAME”))
‘ Context.Response.AddHeader(“Content-Disposition”, “attachment;filename=” & dr (“DOCNAME”))
Context.Response.AddHeader(“content-length”, intLength)
Context.Response.AddHeader(“Pragma”, “public”)
Context.Response.AddHeader(“Cache-Control”, “public”)
Context.Response.CacheControl = “public”
Context.Response.BinaryWrite(DirectCast(dr(“DOCDATA”), Byte()))
Context.Response.End()
dR = nothing
end If
Ds = nothing
Sqlcmd = nothing
Sqlcon = nothing
Sda = nothing

Now the main important point here is content – disposition, and content type
Content type is basically type of content which we are going to download like, JPEG, word, text, etc
And content disposition describe that whether you want download the file or open in browser.
If you want to open in browser then use “inline” and if you want to download then use “attachment” in disposition setting.

So in this way we easily download and kind of file.
If you feel any kind of suggestion, discussions feel free to contact.

Thanks & Esteemed Regards
Rajat Jaiswal
Samsung Epic 4G Android Phone (Sprint)

Create Multilevel Grid in 5 Minutes in 5 easy steps

Hello Friends ,
Today we will create multilevel grid in simplest manner. So here I go.
Here for example I am taking northwind database and our requirment is to determine Category & its products.
Means category is parent and product is chid.Now here are some basic steps just follow it and you will get hierachical grid.
Step 1:- Drag drop a dataGrid on page and define column according to your need.
@@asp:DataGrid ID=”dgCategoryParent” runat=”server” AutoGenerateColumns=”False$$
@@Columns$$
@@asp:BoundColumn DataField=”CategoryId” Visible=”false”@@ @@/asp:BoundColumn$$
@@asp:TemplateColumn$$
@@HeaderTemplate$$
@@table border=”1″ width=”100%”$$
@@tr$$
@@td width=”1″$$   @@/td$$
@@td$$ Category @@/td$$
@@td$$Description @@/td$$
@@/tr$$
@@/table$$
@@/HeaderTemplate$$
@@ItemTemplate$$
@@table border=”1″ width=”100%”$$
@@tr$$ @@td width=”1″$$ @@asp:Button ID=”btnTest” runat=”server” Text=”+” /$$
@@/td$$td$$
@@asp:Label ID=”lblCategory” runat=”server” Text=’@@%# DataBinder.Eval(Container, “DataItem.CategoryName”) %$$’$$ @@/asp:Label$$
@@/td$$
@@td$$
@@asp:Label ID=”lblDescription” runat=”server” Text=’@@%# DataBinder.Eval(Container, “DataItem.Description”) %$$’$$@@/asp:Label$$
@@/td$$
@@/tr$$
@@tr$$
@@td colspan=”3″$$
@@asp:DataGrid ID=”dgProductChild” runat=”server” AutoGenerateColumns=”false” CellPadding=”4″
ForeColor=”#333333″ GridLines=”Both” $$
@@FooterStyle BackColor=”#5D7B9D” Font-Bold=”True” ForeColor=”White” /$$
@@EditItemStyle BackColor=”#999999″ /$$
@@SelectedItemStyle BackColor=”#E2DED6″ Font-Bold=”True” ForeColor=”#333333″ /$$
@@PagerStyle BackColor=”#284775″ ForeColor=”White” HorizontalAlign=”Center” /$$
@@AlternatingItemStyle BackColor=”White” ForeColor=”#284775″ /$$
@@ItemStyle BackColor=”#F7F6F3″ ForeColor=”#333333″ /$$
@@Columns$$
@@asp:BoundColumn DataField=”productName” HeaderText=”Product”$$@@/asp:BoundColumn$$
@@asp:BoundColumn DataField=”UnitPrice” HeaderText=”Unit price”$$@@/asp:BoundColumn$$
@@asp:BoundColumn DataField=”Quantityperunit” HeaderText=”Quantity per unit”$$@@/asp:BoundColumn$$
@@/Columns$$
@@/asp:DataGrid$$
@@/td$$
@@/tr$$
@@/table$$
@@/ItemTemplate$$
@@/asp:TemplateColumn$$
@@/Columns$$
@@HeaderStyle BackColor=”#5D7B9D” Font-Bold=”True” ForeColor=”White” /$$
@@/asp:DataGrid$$

Step 2:-
Now step 2 is to bindGrid for this we have wrote following code.
Remember here we just binding our first data which is related to parent means “Category”

Dim sqlcon As New SqlConnection(strCONNECTIONSTRING)
sqlcon.Open()
Dim sqlcmd As New SqlCommand
sqlcmd.CommandText = "SELECT categoryId,categoryName,description FROM categories"
sqlcmd.CommandType = CommandType.Text
sqlcmd.Connection = sqlcon
Dim ds As New DataSet
Dim sda As New SqlDataAdapter
sda.SelectCommand = sqlcmd
sda.Fill(ds)
Me.dgCategoryParent.DataSource = ds
Me.dgCategoryParent.DataBind()
sqlcon.Close()
sqlcon = Nothing

Step 3:- Now as we now there is row data Bound event on this event our action is to bind
So just find the child control ” product DataGrid ” and bind it. As shown below

Protected Sub dgCategoryParent_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgCategoryParent.ItemDataBound
Try
Dim blnBind As Boolean = False
Select Case e.Item.ItemType
Case ListItemType.Item
blnBind = True
Case ListItemType.AlternatingItem
blnBind = True
Case Else
blnBind = False
End Select
If blnBind = True Then
Dim intId As Integer = e.Item.Cells(0).Text
Dim MyGrid As DataGrid
Dim mybtn As Button
mybtn = CType(e.Item.FindControl("btnTest"), Button)
MyGrid = CType(e.Item.FindControl("dgProductChild"), DataGrid)
If MyGrid Is Nothing = False AndAlso mybtn Is Nothing = False Then
mybtn.Attributes.Add("Onclick", "javascript: return myvisiblity('" & mybtn.ClientID & "','" & MyGrid.ClientID & "')")
Me.pvtBindProductForCategory(intId, MyGrid)
End If

End If
Catch ex As Exception
Throw ex
End Try
End Sub




Step 4:- more over if you want collapse property than add a button on main row and apply java script on it. see below function for it

myvisiblity(str, gridId) { var myBtn1 = document.getElementById(str) var mygrid1 = document.getElementById(gridId); if (myBtn1.value == "+") { mygrid1.style.display = 'none'; myBtn1.value = "-"; } else { mygrid1.style.display = 'block'; myBtn1.value = "+"; } return false; }
You will find a collasible datagrid.


Step 5 : here is your final output



Manhattan Toy Infant Stim-Mobile


I hope you understand the startegy here.

You can download code at
Enjoy programming!

Thanks & Esteemed Regards
Rajat Jaiswal

How to improve AJAX page Speed with 5 easy steps

Hello friends,

Many times we face the Ajax speed problem. Our AJAX page is very slow.

So here I am with five valuable tips checkout if it helps you some where.

1) EnablePartialRendering:-

Make enable partial rendering = true in script manager

Its syntax is as shown below


asp:ScriptManager ID=”scm” runat=”server” EnablePartialRendering =”true” ”

It enable partial rendering so use does n’t have to wait a long for page.

Remember its useful only when you have multiple panel update.

2) Script Refrence Profiler dll:-

This is one of the most important DLL by which you can imporve your page performance.

Its simple in use you have to do just drag and drop Script refrence profiler in Div. Then run the page it will give you all refrence Scripts.

As shown below fig.



Just copy this and page in script tag of Script manager as shown below.

asp:ScriptManager ID=”scm” runat=”server” EnablePartialRendering =”true” >

Scripts

asp:ScriptReference path=”../Includes/Scripts/System.Web.Extensions/1.0.61025.0/MicrosoftAjax.js”/

/script>

/asp:scriptManager

3) Script Mode=”Release”:-

Try to make script mode always release for better performance.

You have to do following setting



4) LoadScriptBeforeUI=”false”:-

This should be false for better result. When you do this then screen comes fast.

5) Composite Script:-

If you are using Asp.net 3.5 with service pack 1 then there will be a nice tag which is called Composite script tag.

By the name its clear that it composite all the script its syntax is as follows.

asp:ScriptManager ID=”scm” runat=”server” ScriptMode =”Release”

CompositeScript ScriptMode =”Release”

Scripts

Samsung Jet S8000 Unlocked Phone with 3G, Quad-Band GSM, 5 MP Camera, and 2 GB Memory--International Version No Warranty (Black)

Some useful Terminology (acronyms)

Hello friends,
Cheers!
Here I am with some useful terminology and these acronyms are generally used now days in broad way take a look.
1) ESB : Enterprise Service Bus
2) POX : Plain OLD XML
3) REST: Representational State Transfer
4) SOAP: Simple Object Access Protocol
5) RIA : Rich Internet Application
6) XML : Extensible Markup Language
7) JASON: Java Script Object Notation
DOM : Document Object Modeling
9) XAML : Extensible Application Markup Language
10) LINQ : Language Integrated Query
11) RSS: Really Simple Syndication
12) WCF: Windows Communication Foundation
13) WF: Windows Foundation
14) WPF: Windows Presentation Foundation
15) AJAX: Asynchronous Java script and XML
16) XLST: Extensible Style Sheet Language Transformation
17) INDIGO: Code name of Microsoft windows Communication foundation Technology
18) OSLO: Code name of Microsoft Modeling Technology
19) SOA: Service Oriented Architecture
20) ORCAS: dot net 3.5 Version called ORCAS
21) AVALON: code name of Microsoft Windows Presentation foundation Technology
22) Azure: Microsoft new Operation system Related to Cloud computing
23) Astoria : Code name of Ado.net Data services

I hope you people like it.
Enjoy life with dot net.

Your host
Rajat Jaiswal
Samsung Vibrant Android Phone (T-Mobile)

WPF Windows Persentaion Foundation with me PART- II

Hello friends,
In this session we are going to take a look how do we connect a silver light application with database.
So here I would like to say that there are basically 4 options by which you can handle database in silver light application.
1) WCF for Silver light
2) Ado.net Data Services
3) Web services
4) RIA Services (need to explore more)

Here I will explain how to connect your WPF Silver light application with database using well know Web service.
It’s easy and I think we all already work on some part of Web services.

So let’s start with it.
We have added a silver light navigation project. In navigation silver light project part we have added 2 new pages employee, register page.
Employee page is for show employee list,And register page is for register employee.



Just see project structure as below.



And In web part we have added a new web service with name my services.
Whose functionality to save, updates, Delete, and read all employee record.
As shown in below fig.



Now our next step is how to integrate this web service with silver light.
For this we add a services reference in our navigation project with the help of Add services reference menu as shown below.



Now you can rename name space according to your choice.

If you do not get any error in referencing then till now you are ok with your work.
Now our next step is calling web method in our pages.
Here I am taking first page which is employee list
We are calling web method which returns all employee lists so here we go.

Private Sub EmployeePage_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
Try
Dim myBinding As New ServiceModel.BasicHttpBinding()
Dim myEndPoint As New ServiceModel.EndpointAddress(New Uri(“http://localhost/MyTest/MyWebService.asmx”, UriKind.Absolute))
Dim proxy As New MyWebServiceSoapClient(myBinding, myEndPoint)
proxy.pub_ReadAllDataAsync()
AddHandler proxy.pub_ReadAllDataCompleted, AddressOf proxy_ReadAllEmployeeCompleted

Catch ex As Exception

End Try
End Sub

Private Sub proxy_ReadAllEmployeeCompleted(ByVal sender As Object, ByVal e As myService.pub_ReadAllDataCompletedEventArgs)
Try
Me.myGrid.ItemsSource = e.Result
Catch ex As Exception
Me.HeaderText.Text = ex.InnerException.Message.ToString
End Try
End Sub

Now things to remember here
1) Dim myBinding As New ServiceModel.BasicHttpBinding()
Its shows the binding is http binding
2) Dim myEndPoint As New ServiceModel.EndpointAddress(New Uri(“http://localhost/MyTest/MyWebService.asmx”, UriKind.Absolute))
Here the path can be absolute or relative.

3) Next you have to call web method like we have call here proxy.pub_ReadAllDataAsync()
4) once we have call the method asyncronously then we have to make a event handler like we have create here

AddHandler proxy.pub_ReadAllDataCompleted, AddressOf proxy_ReadAllEmployeeCompleted

5) when the asyncronous method is complete we have to take result complete argument and covert according to our requirement.
I have just bind the result to datagrid and get below screen.
Just see below.



So friends in this way we can call web service in a Silverlight application.

Still we can use DataServices, RIA services, and WCF services for data manipulation application.

Hope in next few chapter we will take this example and work on it.

That’s all friends, thanks for reading the article.

Happy programming!

Thanks
Rajat
CECT i68+ Unlocked Touch Screen Cell Phone Dual SIM Card GSM Quad Band AT&T T-Mobile & other GSM networks - No Contract Required

WPF Windows Persentaion Foundation with me PART- I

Hello friends,

Today we will discuss one of the most popular technologies which are silver light.
Before going forward you have some query in your mind. As I have so we will first solve that. See following questions.
1. What is Silver light?
Answer: – Silver Light is programmable web browser plug in, that enable feature such like vector graphics, animation and audio, video play back. It provide cross browser compatibility.
Its main aim to provide RIA (Rich Internet Application).Its Consistency with WPF (Windows Presentation Foundation). XAML (extensible Application Markup Language) is base of Silver light.
Its main use to provide end user a rich web application experience
Silver light basically used for RIA (Rich Internet Application) and with help of it we can make user friendly and all browser supported web sites.

2. What is XAML?
Answer: – XAML is core of Windows Presentation foundation. Its full form is Extensible Application Markup Language it’s just like a xml language with certain fixed tags. Like canvas, rectangle, grid etc…

3) From where I can download toolkit?
Answer: – We can download silver light 3.0 toolkits from http://www.silverlight.net site which is official site.

Here I will explain basic example of silver light. We are going to make a simple add 2 integer programs. I know you all aware of this but I started this for step by step progress in silver light.
For this you have to first install 3.0.
Once you have installed silver light 3.0 you will get following projects in asp.net new project window. Just select silver light application in this.



Once you have selected this then next screen comes up for the web site or web application selection. As shown below. I have selected web application.



After selecting web application project you will get 2 projects in your solution explorer one is for silver light in which there will be .XAML file. And another one is web application which is used to call XAML file in the compile format which is called XAP.


Now we start our actual work of making 2 digit sums in silver light application
For this we have to select mainPage.xaml.
In this XAML page we have to put all the control which is requiring like textbox, label or Text Block and button.
Suppose we have to add a TextBlock in page then see below lines

Here x:Name is like id in our ASPX page it should be unique. Grid.Row = 0 and grid.column =0 shows position in grid.

Now similarly if you want to add a label and Textbox and button then
You have to follow below code.




< Button Name=”btnAdd” Content=”Add” Click=”btnAdd_Click” Width=”100″Grid.Row=”2″ Grid.ColumnSpan=”2″ HorizontalAlignment = “Center” >

So the main this which you have to concentrate for alignment, colors.
In Next post we will come up with some solid project base & tool kit understanding.

till than happy programming.

Thanks
Rajat
Metroid: Other M

Nice utilities for Web Developer

Hello friends,

Today I come up with some useful list which help you in web development and good news is that its all free.
1) “FIREBUG” :-
Basically “FIREBUG” is add in for FireFox. It’s a great utility helps a lot to design web pages. As a developer I am mostly intrested in programming not designing.But this utility help me in solving designing issues. With the help of it you can manage designing ,CSS issues.
You can download this from https://addons.mozilla.org/en-US/firefox/addon/1843
2) Web Development Helper:-
This one is another useful utitly for web developer to improve performance. Its basically help you to determine which page taking how much time to response.It also help other area also like script finding. It has dom Inspector also. You can take help of this tool in various way.
You can download this from http://projects.nikhilk.net/WebDevHelper
3) Deep Zoom composer:- If you are working on Silverlight also then you can use Deep Zoom composer.it has very nice feature for images.
You can dowload this from http://www.microsoft.com/downloads/details.aspx?familyid=457b17b7-52bf-4bda-87a3-fa8a4673f8bf&displaylang=en

So just dowload & use this tools and improve your code.

Happy programming!

Thanks …
Your host
Rajat
BlackBerry Torch 9800 Phone (AT&T)

How to change VS.NET 2008 IDE colorful and make it attractive in 5 minutes?

Hello friends,
I know you are some time bored by same IDE. So here I am helping you out to make your IDE environment colorful as shown below fig.



Microsoft gives you full hands on IDE Environment to make your IDE attractive and enjoy dot net programming.
So for this you have to follow below steps.
1) Go to tool –> import and export Setting


2) Select the option as shown below.


3) In next step you can save your existing IDE Settings as shown below fig.


4)in next step just browse your require IDE settings (all the IDE settings has extension “VSSettings”) Like “rajat.vsSettings” just browse the file and click on finish button and what you will see is amazed cool coloful VS IDE.


I have attached some of the files just rename them with .vsSettings.

1) Colourful black

2) IndianTouch

3)RajatSpecial

Remember to rename this doc file to “.VsSettings”

Just use the wizard and you will get attractive IDE.
So enjoy colorful programming and IDE.
Make your coding colorful.

Thanks & regards
Rajat Jaiswal
Samsung Captivate Android Phone (AT&T)

Basic Threading with dotnet

Hello friends,
Some time I really scared when I listen threading, but when I dive in threading pool its really fun and interesting also.
As per my knowledge what ever I got by learning from different books and web sites I will give you some basic knowledge which you will use and enjoy.
So first thing is what is threading? So here we go. When we talk about multi tasking, multi processing then threading word comes in action. Suppose you have a agile code which will run on a button click but the problem is when user click the button its hang up user screen for a while but you want user screen to be free and allow user to do some other task which he wants. Or similar thing in code also.
In this situation you require threading. It will improve user interaction and performance of your code also.

So start with basic the base class in dot net for threading is System.Threading

I will just write a code how to start a thread so it will much better to understand.

Suppose on button click we want to create a thread which will count number
Private Sub btnStartThread_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStartThread.Click

Dim myThread As Threading.Thread = New System.Threading.Thread(New Threading.ThreadStart(AddressOf Me.pvt_NumberCounter))
myThread.Start()
MsgBox(“Next statement after thread!!!!”, MsgBoxStyle.Critical, “Rajat”)

End Sub

In the above lines what we are doing we are creating a delegate for a method which pvt_NumberCounter which count the number and assign it to mythread object.
Then to start thread or to activate thread we wrote mythread.start()
Which make thread active. Method pvt_NumberCounter() get in action.
While after mythread.start() statement message box also execute.
Means controls remain in start thread button.

In this way the thread can start.
There are some states of thread which will call thread state by which we can know what is the current position or state of a thread. For understanding thread you must understand thread state. Go through below fig and table.



Action
ThreadState

A thread is created within the common language runtime.
Unstarted

A thread calls Start
Running

The thread starts running.
Running

The thread calls Sleep
WaitSleepJoin

The thread calls Wait on another object.
WaitSleepJoin

The thread calls Join on another thread.
WaitSleepJoin

Another thread calls Interrupt
Running

Another thread calls Suspend
SuspendRequested

The thread responds to a Suspend request.
Suspended

Another thread calls Resume
Running

Another thread calls Abort
AbortRequested

The thread responds to a Abort request.
Stopped

A thread is terminated.
Stopped
















Now your mind has one question we started Thread, we have seen thread state but how to kill a thread explicitly I know you are very destructive mind : D but it was also in my mind so here is simple property which we have to use.
Which is Abort(). Sounds interesting.
You can kill a thread explicitly by thread.abort() statement.
So friends its over for me for this article i will bring some more stuff later on.
till then keep programming, keep visiting.
Thanks
Rajat
Kindle Wireless Reading Device, Wi-Fi, 6" Display, Graphite - Latest Generation

Understand ftp with asp.net in 5 Minutes Part- IInd

Hello Friends,

In last article we have did how to upload a file I know you are very eager to know how to download a file. I am not taking much time here and will introduce you below code by which you can download a file. It just likes our earlier upload ftp file.Its screen is just like below.



On the button click we did following thing

Protected Sub btnDownload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDownload.Click

Try

Dim ftpRes As FtpWebRequest = DirectCast(FtpWebRequest.Create(Me.txtFtp.Text & “/” & Me.txtRemoteFileName.Text), FtpWebRequest)

ftpRes.Credentials = New NetworkCredential(Me.txtUserName.Text, Me.txtPassword.Text)

ftpRes = DirectCast(WebRequest.Create(Me.txtFtp.Text & “/” & Me.txtRemoteFileName.Text), FtpWebRequest)

ftpRes.Credentials = New NetworkCredential(Me.txtUserName.Text, Me.txtPassword.Text)

ftpRes.Method = WebRequestMethods.Ftp.DownloadFile

ftpRes.UseBinary = True

Dim myFtpWebResponse As FtpWebResponse = ftpRes.GetResponse()

Dim myStreamWriter As StreamWriter

myStreamWriter = New StreamWriter(“c:\Downloads\” & Me.txtRemoteFileName.Text)

myStreamWriter.Write(New StreamReader(myFtpWebResponse.GetResponseStream()).ReadToEnd)

myStreamWriter.Close()

myFtpWebResponse.Close()

Catch eh As System.Net.WebException

Response.Write(eh.Message)

Catch ex As Exception

Throw ex

End Try

End Sub

Here The main important thing is method which is download file as you see in above code.

We just take response of ftp and read the stream of this with the help of GetResponseStream().ReadToEnd.

Rest all the thing is same like our old code for file upload.

I hope you got with the above code.

Thanks & Enjoy coding

Your host

Rajat Jaiswal
The Adventures of Sherlock Holmes

Finding Refrences of table ,function in Sql Server by simple query

Hello Friends,
Most of the time you need how many refrences for particulare table, function or procedure.
In that case if you are not aware of command which I am showing below you will do lot of work.
But if you see below command
It helps you a lot in finding your refrences

SELECT *
FROM sys.procedures
WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE ‘%tblStudent%’
Here in like you can put tableName, function name or store procedure name what ever you want.
And you will got supprise when the result came. It will give you all the refrences related to that particular name.

So enjoy SQL SERVER.
Enjoy tricks.

Thanks
Rajat Jaiswal
Toy Story 3 (Four-Disc Blu-ray/DVD Combo + Digital Copy)

Understand FTP with asp.net in 5 minutes part-Ist

Hello Friends,
Today I am going to share you new thing in asp.net 2.0 which is “FTP object”. Earlier in dot net 1.1 versions there is many problem to handle “FTP”, means if you want to upload or download a file then you have to do socket programming.
Which I don’t like really but after 2.0 this problem is resolved dot net provide great solution which allow us to connect with ftp and do operation.
I will explain you with my example. So today we took how to upload a file on ftp.
For this I have design following page.


On this page there is 3 text box & file upload control basically which is
txtFtp – which keep ftp url like ftp://myftp.com
txtUserName – which keep ftp username for credential
txtPassword – which keep ftp password for credential
ctrlFlup – which keep path from where we have to upload file.

There is a button which is btnUpload on page. On click of this page we are going to upload the selected file.
So in code behind our first and most important statement is import J
Just see below code
Imports System.Net
Imports System
Imports System.Net
Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
Try
Dim ftpRes As FtpWebRequest = DirectCast(FtpWebRequest.Create(Me.txtFtp.Text & “/” & Me.ctrlflUp.FileName), FtpWebRequest)
ftpRes.Credentials = New NetworkCredential(Me.txtUserName.Text, Me.txtPassword.Text)
ftpRes.Method = System.Net.WebRequestMethods.Ftp.UploadFile
Dim b As Byte() = Me.ctrlflUp.FileBytes
Dim fstream As System.IO.Stream = ftpRes.GetRequestStream()
fstream.Write(b, 0, b.Length)
fstream.Close()
fstream.Dispose()
Dim myresponse As FtpWebResponse = DirectCast(ftpRes.GetResponse, FtpWebResponse)
Response.Write(myresponse.StatusDescription)
Catch eh As System.Net.WebException
Response.Write(eh.Message)
Catch ex As Exception
Throw ex
End Try
End Sub
End Class

Here I will explain you the ftpwebrequest is the object which interact with FTP.
So when button upload is click we first create a object of ftp web request.
Once the object is created its credential is required for which we create a new network credential and just pass username & password.
After this you will find another important statement which is Web Request method.
Basically its notify that what user want to do import file, upload file, change directory etc.
In Next step what ever the file which we want to upload just convert that in byte array.
By file upload object as shown below
Dim b as byte() = me.ctrlflUp.fileBytes()
Once it done we just create a stream to write file on ftp.
So we just create a IO stream and write file on ftp.
To get response from Ftp as you know FTP has special command and status so we use ftp web response object.
If there is proper status then we can say our file is uploaded successfully.
In next Session we are going to download file from ftp with the help of this object.
Till then enjoy programming
Enjoy ftp.

Your friend
Rajat Jaiswal
Kindle Wireless Reading Device, Wi-Fi, 6" Display, Graphite - Latest Generation

How to read Resource files in our code by LINQ to XML ?

How to read Resource files in our code by LINQ to XML ?

Hello friends,

Sorry for such a late post. Currently I am busy in too many works so not getting enough time to talk with you.

Today I am posting an interesting work which is how to read a resource file in our code with the help of LINQ TO SQL.

I can say only one thing which is its simple and easy to use. Just copy paste below code and you will get what to want.

Before code I will explain you that resource file is just like xml which has attributes and value and that particular attributes is your key.



Now we need to fetch value for particular key for a file for this you have to write below code. Where bv_strFileName is your resource file name and bv_strKey is key for which you need value.

Public Shared Function pub_LangaugeValue(ByVal bv_strFile As String, ByVal bv_strKey As String) As String

Try

Dim strValue As String = “”

Dim resxXML As New XDocument

resxXML = XDocument.Load(bv_strFile)

Dim a = From data In resxXML.Root.Descendants(“data”) _

Where data.Attribute(“name”).Value = bv_strKey _

Select New With {.resxA = data.Attribute(“name”).Value, .ResxValue = data.Element(“value”).Value}

If a.Count() > 0 Then

strValue = a.FirstOrDefault().ResxValue.ToString()

Else

strValue = bv_strKey

End If

Return strValue

Catch ex As Exception

Throw ex

End Try

End Function ‘pub_LangaugeValue



Where bv_strFileName is full path name of our resource file and bv_strkey is the key for which we need to find the value.

Below is example how to use it our aspx.

Suppose we want to read LabelResource1.text value in Spanish whose file name is home.aspx.es.resx.



Then we have to call the above function like below.

Response.write(pub_LanguageValue(server.mapPath(“/App_LocalResources/home.aspx.es.resx”),”LabelResource1.text”)

With the help of above code.

We can get key’s value from different resource file.

I Dreamed A Dream

Thanks

Rajat Jaiswal

Finding Refrences of table ,function in Sql Server by simple query

Hello Friends,
Most of the time you need how many refrences for particulare table, function or procedure.
In that case if you are not aware of command which I am showing below you will do lot of work.
But if you see below command
It helps you a lot in finding your refrences

SELECT *
FROM sys.procedures
WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE ‘%tblStudent%’
Here in like you can put tableName, function name or store procedure name what ever you want.
And you will got supprise when the result came. It will give you all the refrences related to that particular name.

So enjoy SQL SERVER.
Enjoy tricks.

Thanks
Rajat Jaiswal
Kindle Wireless Reading Device, Wi-Fi, 6" Display, Graphite - Latest Generation

WCF Windows Communication Foundation in 5 minutes Part 1

Hello Friends,

Today I am going to discuss new topic which is WCF.

As you know today market demand is Services. Every company needed Service Oriented Architecture (SOA) and in SOA first and basic thing is communication for service so Microsoft provide a new way of communication for services which is WCF. So let’s start with our questionnaires.

1. What is WCF?

Its full name is Windows Communication Foundation. It’s also called Indigo. Its basically introduce in Dot net 3.0.

WCF is new way of communication between client & server. Its technology by which a client & server can communicate with each other. It provides direct support for Service orientation. Its help in distributed application creation its work as separate layer for communication.

Or in other way we can say that its combination of

1) .Net Remoting

2) MSMQ

3) Web Services

4) COM +

Its basically provide Service.

The Mail dll for this is “System.ServiceModel.dll” and main Namespace Is ” System.ServiceModel”

In WCF there are 3 basic conceptual parts.

1) Services: – The Services are programs which respond to clients. They can send or receive Messages.

2) Client: – Client is that program which consume services the request for services. They either send messages or receive messages or both.

3) Intermediaries: – that’s server as bridge between client & services as shown in below fig.



2. What’s advantage?

Now as a human tendency you will think “Why?” While we have Dot net Remotings, Web Services MSMQ, DCOM then why Microsoft introduces the “WCF” indigo.

So I will say that Microsoft Sees future. Now the era is For SOA (Service Oriented Architecture). So that’s the time demand to come with solid technology which can communicate Dot net to dot net application + dot net to Other language Application too.

When you talking about dot net to dot net application then in that case Remoting is perfect.

But when you talking about dot net to other application Web Services is perfect. But when you talking about both the things at same time then?

At that time WCF is most perfect.

Now here if you go in deep Remoting use TCP/IP protocols for communication & web services stick with SOAP or http.

So Microsoft takes WCF in picture which is much flexible.

Other than that there are few more advantages

SOA: – Its provide Service Oriented Architecture. It provides developer to make just a simple Config base communication model.

So just define your services and use those services according to you.

Interpretability: – WCF provide Interpretability. It integrates with other technologies also and gives great way to work with them.

Ws-* :- WCF follows Ws-* specification which are define by Microsoft, SUN, IBM and many other big company together so that they can expose there services with common protocol.

3. Necessary component?

There are following WCF which are as below:-

1) Contract Definition: – A Service must have a service contact. It can contain multiple Service contract, Data Contract or operational contract.

2) End point Definition: – Address binding contract for binding necessary

3) Hosting code: Some hosting code needed to create service & start services

In other word we can say service class also needed.



4. How it works?

To understand the WCF you have to learn ABC doesn’t laugh on it: D. Here ABC means Address Binding Contact.

Here A- Address says where there is service or which services we have to contact.

B- Binding says How to contact with services which ways we have to connect.

C- Contract means what part of services which we have to access.



We will study in detail in my next post with sample code.

So just wait for 2nd part of this till than

Thanks & Esteemed Regards

Rajat
Triple Exposure