Posts

Showing posts from August, 2013

Close The Reader First Problem in Asp.net When Read Data From SQL Server

Yesterday I was trying to fetch data from SQL server with the help of SqlDataReader but I got an error message " open DataReader associated with this Command which must be closed first " I search a lot on internet and got a solution regarding this problem. It was advised by someone that when you are reading data from server and trying to insert, delete or update action with the same connection then you will face such error which will told you to close the reader first. To get the solution for this problem you should do two things. 1. Use SqlDataAdapter and Fill command when you do not want to make an other connection for insertion and other things other than read. 2. use separate sql connection for insert, delete or update action. i.e when you have a SQL Connection 'Con' for reader. Then you should use other SQL Connection for other action. Someone also advised to add MultipleActiveResultSets=Truein connection string. Hope this will help you a lot...

Delete Duplicate Entry & Update Table By Copying Data From One Table to Other

Image
Suppose you want to take regular updates from various servers and store them in your own database for any valid reason. Then you will face problem of duplicate entry in your database. To understand this suppose you want to store various RSS Feeds news for further analysis then you will automatically refresh your page in certain time interval but in such situation your database will capture various duplicate entry also. To avoid such thing happen with you you will have to manage it will proper algorithm. Okay look at this technique and i hope this will help you a lot. 1. Take Two Table named as "FirstTable" and "SecondTable". Second Table will be your main table which stores actual data without duplicate entry. First Table will store updates only. 2. With the help of some logic we first take our updates first to "FirstTable" and then we will check weather "SecondTable" has same rows or columns. 3. If it has same rows and columns then delete

Display RSS Feeds in Your Website & If Needed How to Store Them in DataBase

Image
RSS Feeds comes in the XML format and we all know that there is a start tag and other are child tag of start tag in XML format. You can read more about RSS Feeds and It's format or For simply overview you can read it from here. All the data comes in RSS Feeds like this- <rss version="2.0"> <channel>   -----   ----- <item>   ---   --- </item> </channel> </rss> to get the element inside RSS Feeds we will have to first select it's parent tag suppose..if we want title of any RSS then we will have to first select Channel tag the go to next step. like this.. XmlDocument doc = new XmlDocument (); doc.Load(" http://timesofindia.indiatimes.com/rssfeeds/1081479906.cms "); XmlNodeList a = doc.SelectNodes(" rss/channel/item ");  as from the above code it is clear that we are going to do some thing with inside the  <item></item> tag that's why we selected node with the help

Upload and Display YouTube Video in Asp.Net

Image
In this tutorial I will teach you how to upload youtube video in database and display it in various style in web page in asp.net using C#. So, here we go... Make a database table with any name as you wish and give three column 1. ID which will be primary key and will auto increase. 2. UserID user name either from session or from simple inserting name every time when upload video. 3. VideoLink for storing video link from youtube page. YouTube video will not play on you web page until you convert it in embedded video so how to check which video is embedded and which one is not. look at the image   but when a user upload or share any youtube video he or she will not upload embedded video but he or she will upload simple URL of any video so we need to convert general URL in embedded URL by this way using C#. string s = TextBox1.Text string g = " embed/ ";         string o = " watch?v= ";         string m = s.Replace(o, g);   Here string s co

Upload YouTube Video and On Video Click Display in Next Page (Similar to YouTube)

Image
if you are looking for to make a website similar to YouTube Then You are At right place. I will not tell yo to make complete web site like YouTube but will give some idea to solve particular problems like 1. How to upload YouTube Video 2. How to get Thumbnail of YouTube Video in your Database. 3. Onclick Display it in New page and Play there with some details. so here we go..... 1. how to upload video in Database.     you do not need to upload video to your database because your hosting company will not give huge data storage. So you should keep only link of that video when user upload this take link of that image. so I have link for you already above you can do it easily. Do not worry i will do it here this again. 1. First of all create a data base with some columns like this.   You do not need to make LikeCount and ViewCount because i have this for to collect like and hits on my site.Here we will store our data in server in those columns. In you Asp page create a text

Problem While Inserting Data In SQL Server In Asp.Net

Today I faced a problem while inserting data in SQL Server. The problem was that when I Click on insert button then it insert some data values in another columns while assigned columns values was correct i.e. suppose i have two columns "Name" & "Address" then Address values goes to Name column and Address column is left blank. Every thing was correct in coding not even a single line was in mistake but still this was problem for me. If you face such type of problem when you are not using SQL Stored Procedure.  Then you should use SQL Stored Procedure to insert data value because this may be problem of server or any thing else. If any body has the same problem then share your experience. thank you