Saturday, December 19, 2009

Data Accessing vai Stored Procedures

String cs = "Data Source=.\\SQLExpress; Initial Catalog= AdventureWork"
using (System.Data.SqlClient.SqlConnection Con = new System.Data.SqlClient.SqlConnection())
{
con.Open();
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
cmd.Connection = con;
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.CommandText = "EmployeeByState"; //name of the stored procedure

cmd.Parameters.Add("@StateProvinceCode", System.Data.SqlDbType.NChar,3);
cmd.Parameters["@StateProvinceCode"].Value = "WA"; //passing parameters to the SP
using (System.Data.SqlClient.SqlDataReader reader = cmd.ExecuteReader())
{
gridview1.DataSource = reader;
gridview1.DataBind();
}
}

Friday, August 28, 2009

How to Install IIS 7 & Setup a Static Website in 13 Easy Steps

http://www.trainsignaltraining.com/windows-server-2008-iis7/2008-03-21/

Thursday, August 6, 2009

Solving Report Viewer Rendering Issue on ISS7

http://otkfounder.blogspot.com/2007/11/solving-reportviewer-rendering-issue-on.html

Thursday, June 25, 2009

Install Apache, MySQL, PHP and PHPMyAdmin on Ubuntu

First we have to install Apache. Open a terminal (Applications >> Accessories >> Terminal). Then type the following command.
  • sudo apt-get install apache2
After compleated that you can test for apache. Open your web browser and try to access the following URL.
  • http://localhost
If you have successfully installed that then you can see some text on your browser.

Then we can install PHP. Run following command on terminal for that.
  • sudo apt-get install php5
Now we have to install MYSQL. Use following command for that.
  • sudo apt-get install mysql-server
To administrate MYSQL you have to use PHPMyAdmin, which is an web based interface for this purpose. To do that run following command on terminal.
  • sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin
While installing this it may ask you to select the webserver. then you have to select "apache2".

Finally you have to set the path for PHPMyAdmin. Follow the following steps,
  • sudo gedit /etc/apache2/apache2.conf
Then insert the following line and save it.
  • Include /etc/phpmyadmin/apache.conf
Then restart the apache,
  • sudo /etc/init.d/apache2 restart
Then try to access phpMyAdmin using web browser,
  • http://localhost/phpmyadmin/
Thats it..! :)

Monday, March 30, 2009

Configure the USB ADSL modem on Linux

UbuDSL is a tool that helps you configure the ADSL connection using a USB modem on the Linux Operating System. Currently supported distributions are openSUSE 10.3+ and Ubuntu 8.04+. It is designed in the way to minimize user actions. All you have to do is simply to run the application, choose a predefined settings or customize you own options.

Please Refer the following URL to download the UbuDSL tool,
http://www.ubudsl.com/en/download.php

Wednesday, March 11, 2009

How to repair the GRUB..

I have been using both Windows XP and Ubuntu 8.04 as the operating systems in my laptop. But after formatting the Windows XP OS of my laptop, I had no way of accessing the ubuntu partition. I was wondering whether I will have to reinstall ubuntu in my laptop. Then I found the solution. The following steps will lead you to repair the GRUB and reaccess the unseen ubuntu partition, if you have the same problem.

1. Boot the PC or Laptop with an Ubuntu Live CD.

2. Open a Terminal

3. Type the following command..

sudo grub

4. Type the following followed by the TAB key

root (hd

5. This will show the list of physical drives.

6. Type the number of the drive you installed ubuntu on,.

7. If you are not sure about the ubuntu installed drive add a ‘,‘ after the number and press theTAB key again.

root (hd0,

8. This will enable you to see something like following,

grub> root (hd0,
Possible partitions are:
Partition num: 0, Filesystem type unknown, partition type 0×7
Partition num: 1, Filesystem type is ext2fs, partition type 0×83
Partition num: 2, Filesystem type unknown, partition type 0×7
Partition num: 3, Filesystem type is fat, partition type 0xb
Partition num: 4, Filesystem type is fat, partition type 0xb

9. The ext2fs partition is the one Ubuntu is installed partition of your machine. 

10. The type the following with replacing 1 with the ubuntu installed partition num of your mechine.

root (hd0,1) 

11. Finally type the following, replacing hd0 with the physical drive Ubuntu is installed

setup (hd0)

This worked out fine for me. Hope it will work with you too. Let me know if there are any issues.

Cheers!!

Tuesday, March 10, 2009

Copy a table from one database to another in SQL Server 2005

If you have a table in a database and you would like to copy the table to another database, use this query:

SELECT * INTO AdventureWorks.dbo.CustomersTemp FROM Northwind.dbo.Customers

Just remember that using this query will only transfer the schema and data. It does not transfer the indexes, foreign keys, statistics etc.

If you want to transfer all the objects from one database to another, open Sql Server Management Studio > Right click on your database > All Tasks > Generate SQL Scripts. Then run these scripts against the new database.

Transfer both schema and data

To copy both data and schema, use the Microsoft SQL Server Database Publishing Wizard 1.1. This tool works for both SQL 2000 and SQL 2005 and generates a single SQL script file which can be used to recreate a database (both schema and data).

Monday, February 23, 2009

How to disable autorun in pen drive

go to start-> run  type gpedit.msc
Now from Computer configuration click administrative templates> system
there at the right pane look for "turn off autoplay".
See that its set as not configured.
select enabled and then select 'all drives'.
for more information visit How to get rid of pendrive viruses 

Monday, February 16, 2009

Stored Procedure to Insert and Update

INSERT

/*
 * Create a stored procedure to insert a product.
 */
CREATE PROCEDURE dbo.ttInsertProduct
(
@ProductName nvarchar(40),
@SupplierID int,
@CategoryID int,
@QuantityPerUnit nvarchar(20),
@UnitPrice money,
@UnitsInStock smallint, 
@UnitsOnOrder smallint, 
@ReorderLevel smallint,
@Discontinued bit
)
AS
INSERT Products 
(
ProductName,
SupplierID,
CategoryID,
QuantityPerUnit,
UnitPrice,
UnitsInStock, 
UnitsOnOrder, 
ReorderLevel,
Discontinued 
)
VALUES
(
@ProductName,
@SupplierID,
@CategoryID,
@QuantityPerUnit,
@UnitPrice,
@UnitsInStock, 
@UnitsOnOrder, 
@ReorderLevel,
@Discontinued
)

RETURN
GO

UPDATE

/*
 * Create a stored procedure to update a product.
 */
CREATE PROCEDURE dbo.ttUpdateProduct
(
@ProductID int,
@ProductName nvarchar(40),
@SupplierID int,
@CategoryID int,
@QuantityPerUnit nvarchar(20),
@UnitPrice money,
@UnitsInStock smallint, 
@UnitsOnOrder smallint, 
@ReorderLevel smallint,
@Discontinued bit
)
AS
UPDATE Products SET
ProductName = @ProductName,
SupplierID = @SupplierID,
CategoryID = @CategoryID,
QuantityPerUnit = @QuantityPerUnit,
UnitPrice = @UnitPrice,
UnitsInStock = @UnitsInStock, 
UnitsOnOrder = @UnitsOnOrder, 
ReorderLevel = @ReorderLevel,
Discontinued = @Discontinued 
WHERE 
ProductID=@ProductID

RETURN
GO